1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
const { promiseStartupManager, promiseShutdownManager } = AddonTestUtils;
const openSearchEngineDescriptions = [
{
file: "secure-and-securely-updated1.xml",
name: "secure-and-securely-updated1",
description: "Secure and securely updated 1",
searchForm: "https://example.com/ss1",
searchUrl: "https://example.com/ss1?q=foo",
updateUrl: "https://example.com/ss1.xml",
},
{
file: "secure-and-securely-updated2.xml",
name: "secure-and-securely-updated2",
description: "Secure and securely updated 2",
searchForm: "https://example.com/ss2",
searchUrl: "https://example.com/ss2?q=foo",
updateUrl: "https://example.com/ss2.xml",
},
{
file: "secure-and-securely-updated3.xml",
name: "secure-and-securely-updated3",
description: "Secure and securely updated 3",
searchForm: "https://example.com/ss3",
searchUrl: "https://example.com/ss3?q=foo",
updateUrl: "https://example.com/ss3.xml",
},
{
file: "secure-and-insecurely-updated1.xml",
name: "secure-and-insecurely-updated1",
description: "Secure and insecurely updated 1",
searchForm: "https://example.com/si1",
searchUrl: "https://example.com/si1?q=foo",
updateUrl: "https://example.com/si1.xml",
},
{
file: "secure-and-insecurely-updated2.xml",
name: "secure-and-insecurely-updated2",
description: "Secure and insecurely updated 2",
searchForm: "https://example.com/si2",
searchUrl: "https://example.com/si2?q=foo",
updateUrl: "https://example.com/si2.xml",
},
{
file: "insecure-and-securely-updated1.xml",
name: "insecure-and-securely-updated1",
description: "Insecure and securely updated 1",
searchForm: "https://example.com/is1",
searchUrl: "https://example.com/is1?q=foo",
updateUrl: "https://example.com/is1.xml",
},
{
file: "insecure-and-insecurely-updated1.xml",
name: "insecure-and-insecurely-updated1",
description: "Insecure and insecurely updated 1",
searchForm: "https://example.com/ii1",
searchUrl: "https://example.com/ii1?q=foo",
updateUrl: "https://example.com/ii1.xml",
},
{
file: "insecure-and-insecurely-updated2.xml",
name: "insecure-and-insecurely-updated2",
description: "Insecure and insecurely updated 2",
searchForm: "https://example.com/ii2",
searchUrl: "https://example.com/ii2?q=foo",
updateUrl: "https://example.com/ii2.xml",
},
{
file: "secure-and-no-update-url1.xml",
name: "secure-and-no-update-url1",
description: "Secure and no update URL 1",
searchForm: "https://example.com/snu1",
searchUrl: "https://example.com/snu1?q=foo",
updateUrl: null,
},
{
file: "insecure-and-no-update-url1.xml",
name: "insecure-and-no-update-url1",
description: "Insecure and no update URL 1",
searchForm: "http://example.com/inu1",
searchUrl: "http://example.com/inu1?q=foo",
updateUrl: null,
},
{
file: "secure-localhost.xml",
name: "secure-localhost",
description: "Secure localhost",
searchForm: "http://localhost:8080/sl",
searchUrl: "http://localhost:8080/sl?q=foo",
updateUrl: null,
},
{
file: "secure-onionv2.xml",
name: "secure-onionv2",
description: "Secure onion v2",
searchForm: "http://s3zkf3ortukqklec.onion/sov2",
searchUrl: "http://s3zkf3ortukqklec.onion/sov2?q=foo",
updateUrl: null,
},
{
file: "secure-onionv3.xml",
name: "secure-onionv3",
description: "Secure onion v3",
searchForm:
"http://ydemw5wg5cseltau22u4fjfrmfshopaldpoznsirb3rgo2gv6uh4s2y5.onion/sov3",
searchUrl:
"http://ydemw5wg5cseltau22u4fjfrmfshopaldpoznsirb3rgo2gv6uh4s2y5.onion/sov3?q=foo",
updateUrl: null,
},
];
async function verifyTelemetry(probeNameFragment, engineCount, type) {
Services.telemetry.clearScalars();
await Services.search.runBackgroundChecks();
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent"),
`browser.searchinit.${probeNameFragment}`,
engineCount,
`Count of ${type} engines: ${engineCount}`
);
}
add_task(async function setup() {
useHttpServer("opensearch");
await promiseStartupManager();
await Services.search.init();
for (let engine of openSearchEngineDescriptions) {
await Services.search.addOpenSearchEngine(gDataUrl + engine.file, null);
}
registerCleanupFunction(async () => {
await promiseShutdownManager();
});
});
add_task(async function() {
verifyTelemetry("secure_opensearch_engine_count", 9, "secure");
verifyTelemetry("insecure_opensearch_engine_count", 4, "insecure");
verifyTelemetry("secure_opensearch_update_count", 4, "securely updated");
verifyTelemetry("insecure_opensearch_update_count", 4, "insecurely updated");
});
|