Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
5 // This verifies that background updates & notifications work as expected
7 // The test extension uses an insecure update url.
8 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
10 Components.utils.import("resource://testing-common/httpd.js");
11 var testserver = new HttpServer();
12 testserver.start(-1);
13 gPort = testserver.identity.primaryPort;
14 const profileDir = gProfD.clone();
15 profileDir.append("extensions");
17 // register static files with server and interpolate port numbers in them
18 mapFile("/data/test_backgroundupdate.rdf", testserver);
20 function run_test() {
21 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
23 testserver.registerDirectory("/addons/", do_get_file("addons"));
25 startupManager();
27 do_test_pending();
28 run_test_1();
29 }
31 function end_test() {
32 testserver.stop(do_test_finished);
33 }
35 // Verify that with no add-ons installed the background update notifications get
36 // called
37 function run_test_1() {
38 AddonManager.getAddonsByTypes(["extension", "theme", "locale"], function(aAddons) {
39 do_check_eq(aAddons.length, 0);
41 Services.obs.addObserver(function() {
42 Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
44 do_execute_soon(run_test_2);
45 }, "addons-background-update-complete", false);
47 AddonManagerPrivate.backgroundUpdateCheck();
48 });
49 }
51 // Verify that with two add-ons installed both of which claim to have updates
52 // available we get the notification after both updates attempted to start
53 function run_test_2() {
54 writeInstallRDFForExtension({
55 id: "addon1@tests.mozilla.org",
56 version: "1.0",
57 updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.rdf",
58 targetApplications: [{
59 id: "xpcshell@tests.mozilla.org",
60 minVersion: "1",
61 maxVersion: "1"
62 }],
63 name: "Test Addon 1",
64 }, profileDir);
66 writeInstallRDFForExtension({
67 id: "addon2@tests.mozilla.org",
68 version: "1.0",
69 updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.rdf",
70 targetApplications: [{
71 id: "xpcshell@tests.mozilla.org",
72 minVersion: "1",
73 maxVersion: "1"
74 }],
75 name: "Test Addon 2",
76 }, profileDir);
78 writeInstallRDFForExtension({
79 id: "addon3@tests.mozilla.org",
80 version: "1.0",
81 targetApplications: [{
82 id: "xpcshell@tests.mozilla.org",
83 minVersion: "1",
84 maxVersion: "1"
85 }],
86 name: "Test Addon 3",
87 }, profileDir);
89 // Background update uses a different pref, if set
90 Services.prefs.setCharPref("extensions.update.background.url",
91 "http://localhost:" + gPort +"/data/test_backgroundupdate.rdf");
92 restartManager();
94 // Do hotfix checks
95 Services.prefs.setCharPref("extensions.hotfix.id", "hotfix@tests.mozilla.org");
96 Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" + gPort + "/missing.rdf");
98 let installCount = 0;
99 let completeCount = 0;
100 let sawCompleteNotification = false;
102 Services.obs.addObserver(function() {
103 Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
105 do_check_eq(installCount, 3);
106 sawCompleteNotification = true;
107 }, "addons-background-update-complete", false);
109 AddonManager.addInstallListener({
110 onNewInstall: function(aInstall) {
111 installCount++;
112 },
114 onDownloadFailed: function(aInstall) {
115 completeCount++;
116 if (completeCount == 3) {
117 do_check_true(sawCompleteNotification);
118 end_test();
119 }
120 }
121 });
123 AddonManagerPrivate.backgroundUpdateCheck();
124 }