3 let server = createHttpServer({ hosts: ["example.com"] });
5 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "45", "45");
7 Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
8 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
10 // Tests that cookies are not sent with background requests.
11 add_task(async function test_cookies() {
12 const ID = "bg-cookies@tests.mozilla.org";
14 // Add a new handler to the test web server for the given file path.
15 // The handler appends the incoming requests to `results` and replies
16 // with the provided body.
17 function makeHandler(path, results, body) {
18 server.registerPathHandler(path, (request, response) => {
19 results.push(request);
25 makeHandler("/get", gets, JSON.stringify({ results: [] }));
26 Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, "http://example.com/get");
38 update_link: "http://example.com/update.xpi",
50 makeHandler("/update.xpi", xpiFetches, "");
52 const COOKIE = "test";
53 // cookies.add() takes a time in seconds
54 let expiration = Date.now() / 1000 + 60 * 60;
65 Ci.nsICookie.SAMESITE_NONE,
66 Ci.nsICookie.SCHEME_HTTP
69 await promiseStartupManager();
71 let addon = await promiseInstallWebExtension({
74 browser_specific_settings: {
77 update_url: "http://example.com/update",
83 equal(gets.length, 1, "Saw one addon metadata request");
84 equal(gets[0].hasHeader("Cookie"), false, "Metadata request has no cookies");
87 AddonTestUtils.promiseInstallEvent("onDownloadFailed"),
88 AddonManagerPrivate.backgroundUpdateCheck(),
91 equal(updates.length, 1, "Saw one update check request");
92 equal(updates[0].hasHeader("Cookie"), false, "Update request has no cookies");
94 equal(xpiFetches.length, 1, "Saw one request for updated xpi");
96 xpiFetches[0].hasHeader("Cookie"),
98 "Request for updated XPI has no cookies"
101 await addon.uninstall();