Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_bug1883496.js
blob87f96f2121d2bb757a2c2cd834c2e768e37df582
1 "use strict";
2 Services.env.set("MOZ_DISABLE_NONLOCAL_CONNECTIONS", "0");
3 Services.prefs.setBoolPref("network.dns.native-is-localhost", true);
5 async function testHeader(domain, expectHeader, isHttps) {
6 Services.prefs.setCharPref("network.dns.localDomains", "www" + domain);
7 var URL = isHttps ? "https://www" + domain : "http://www" + domain;
9 let { req } = await new Promise(resolve => {
10 let chan = NetUtil.newChannel({
11 uri: URL,
12 loadUsingSystemPrincipal: true,
13 });
14 chan.asyncOpen(
15 new ChannelListener(
16 req1 => resolve({ req: req1 }),
17 null,
18 CL_EXPECT_FAILURE
21 });
23 if (expectHeader) {
24 Assert.equal(
25 req
26 .QueryInterface(Ci.nsIHttpChannel)
27 .getRequestHeader("X-Search-Subdivision"),
28 "1"
30 } else {
31 Assert.throws(
32 () => {
33 req
34 .QueryInterface(Ci.nsIHttpChannel)
35 .getRequestHeader("X-Search-Subdivision");
37 /NS_ERROR_NOT_AVAILABLE/,
38 "search header missing"
43 add_task(async function googleDomainSearchHeaderChecker() {
44 const googleStandardDomains = [
45 ".google.com",
46 ".google.ad",
47 ".google.ae",
48 ".google.com.af",
49 ".google.com.ag",
50 ".google.al",
51 ".google.am",
52 ".google.co.ao",
53 ".google.com.ar",
54 ".google.as",
55 ".google.at",
56 ".google.com.au",
57 ".google.az",
58 ".google.ba",
59 ".google.com.bd",
60 ".google.be",
61 ".google.bf",
62 ".google.bg",
63 ".google.com.bh",
64 ".google.bi",
65 ".google.bj",
66 ".google.com.bn",
67 ".google.com.bo",
68 ".google.com.br",
69 ".google.bs",
70 ".google.bt",
71 ".google.co.bw",
72 ".google.by",
73 ".google.com.bz",
74 ".google.ca",
75 ".google.cd",
76 ".google.cf",
77 ".google.cg",
78 ".google.ch",
79 ".google.ci",
80 ".google.co.ck",
81 ".google.cl",
82 ".google.cm",
83 ".google.cn",
84 ".google.com.co",
85 ".google.co.cr",
86 ".google.com.cu",
87 ".google.cv",
88 ".google.com.cy",
89 ".google.cz",
90 ".google.de",
91 ".google.dj",
92 ".google.dk",
93 ".google.dm",
94 ".google.com.do",
95 ".google.dz",
96 ".google.com.ec",
97 ".google.ee",
98 ".google.com.eg",
99 ".google.es",
100 ".google.com.et",
101 ".google.fi",
102 ".google.com.fj",
103 ".google.fm",
104 ".google.fr",
105 ".google.ga",
106 ".google.ge",
107 ".google.gg",
108 ".google.com.gh",
109 ".google.com.gi",
110 ".google.gl",
111 ".google.gm",
112 ".google.gr",
113 ".google.com.gt",
114 ".google.gy",
115 ".google.com.hk",
116 ".google.hn",
117 ".google.hr",
118 ".google.ht",
119 ".google.hu",
120 ".google.co.id",
121 ".google.ie",
122 ".google.co.il",
123 ".google.im",
124 ".google.co.in",
125 ".google.iq",
126 ".google.is",
127 ".google.it",
128 ".google.je",
129 ".google.com.jm",
130 ".google.jo",
131 ".google.co.jp",
132 ".google.co.ke",
133 ".google.com.kh",
134 ".google.ki",
135 ".google.kg",
136 ".google.co.kr",
137 ".google.com.kw",
138 ".google.kz",
139 ".google.la",
140 ".google.com.lb",
141 ".google.li",
142 ".google.lk",
143 ".google.co.ls",
144 ".google.lt",
145 ".google.lu",
146 ".google.lv",
147 ".google.com.ly",
148 ".google.co.ma",
149 ".google.md",
150 ".google.me",
151 ".google.mg",
152 ".google.mk",
153 ".google.ml",
154 ".google.com.mm",
155 ".google.mn",
156 ".google.com.mt",
157 ".google.mu",
158 ".google.mv",
159 ".google.mw",
160 ".google.com.mx",
161 ".google.com.my",
162 ".google.co.mz",
163 ".google.com.na",
164 ".google.com.ng",
165 ".google.com.ni",
166 ".google.ne",
167 ".google.nl",
168 ".google.no",
169 ".google.com.np",
170 ".google.nr",
171 ".google.nu",
172 ".google.co.nz",
173 ".google.com.om",
174 ".google.com.pa",
175 ".google.com.pe",
176 ".google.com.pg",
177 ".google.com.ph",
178 ".google.com.pk",
179 ".google.pl",
180 ".google.pn",
181 ".google.com.pr",
182 ".google.ps",
183 ".google.pt",
184 ".google.com.py",
185 ".google.com.qa",
186 ".google.ro",
187 ".google.ru",
188 ".google.rw",
189 ".google.com.sa",
190 ".google.com.sb",
191 ".google.sc",
192 ".google.se",
193 ".google.com.sg",
194 ".google.sh",
195 ".google.si",
196 ".google.sk",
197 ".google.com.sl",
198 ".google.sn",
199 ".google.so",
200 ".google.sm",
201 ".google.sr",
202 ".google.st",
203 ".google.com.sv",
204 ".google.td",
205 ".google.tg",
206 ".google.co.th",
207 ".google.com.tj",
208 ".google.tl",
209 ".google.tm",
210 ".google.tn",
211 ".google.to",
212 ".google.com.tr",
213 ".google.tt",
214 ".google.com.tw",
215 ".google.co.tz",
216 ".google.com.ua",
217 ".google.co.ug",
218 ".google.co.uk",
219 ".google.com.uy",
220 ".google.co.uz",
221 ".google.com.vc",
222 ".google.co.ve",
223 ".google.co.vi",
224 ".google.com.vn",
225 ".google.vu",
226 ".google.ws",
227 ".google.rs",
228 ".google.co.za",
229 ".google.co.zm",
230 ".google.co.zw",
231 ".google.cat",
234 googleStandardDomains.forEach(domain => {
235 testHeader(domain, true, true);
236 //tests if we don't send any header for google-domain http requests
237 testHeader(domain, false, false);
240 //tests if we don't send any header for non-google domains
241 testHeader("googlelike.com", false, true);