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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 // This file is a test-only JSM containing utility methods for
6 // interacting with the add-ons manager.
8 "use strict";
10 this.EXPORTED_SYMBOLS = [
11 "AddonTestUtils",
12 ];
14 const {utils: Cu} = Components;
16 Cu.import("resource://gre/modules/Promise.jsm");
17 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
19 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
20 "resource://gre/modules/AddonManager.jsm");
22 this.AddonTestUtils = {
23 /**
24 * Uninstall an add-on that is specified by its ID.
25 *
26 * The returned promise resolves on successful uninstall and rejects
27 * if the add-on is not unknown.
28 *
29 * @return Promise<restartRequired>
30 */
31 uninstallAddonByID: function (id) {
32 let deferred = Promise.defer();
34 AddonManager.getAddonByID(id, (addon) => {
35 if (!addon) {
36 deferred.reject(new Error("Add-on is not known: " + id));
37 return;
38 }
40 let listener = {
41 onUninstalling: function (addon, needsRestart) {
42 if (addon.id != id) {
43 return;
44 }
46 if (needsRestart) {
47 AddonManager.removeAddonListener(listener);
48 deferred.resolve(true);
49 }
50 },
52 onUninstalled: function (addon) {
53 if (addon.id != id) {
54 return;
55 }
57 AddonManager.removeAddonListener(listener);
58 deferred.resolve(false);
59 },
61 onOperationCancelled: function (addon) {
62 if (addon.id != id) {
63 return;
64 }
66 AddonManager.removeAddonListener(listener);
67 deferred.reject(new Error("Uninstall cancelled."));
68 },
69 };
71 AddonManager.addAddonListener(listener);
72 addon.uninstall();
73 });
75 return deferred.promise;
76 },
78 /**
79 * Install an XPI add-on from a URL.
80 *
81 * @return Promise<addon>
82 */
83 installXPIFromURL: function (url, hash, name, iconURL, version) {
84 let deferred = Promise.defer();
86 AddonManager.getInstallForURL(url, (install) => {
87 let fail = () => { deferred.reject(new Error("Add-on install failed.")) };
89 let listener = {
90 onDownloadCancelled: fail,
91 onDownloadFailed: fail,
92 onInstallCancelled: fail,
93 onInstallFailed: fail,
94 onInstallEnded: function (install, addon) {
95 deferred.resolve(addon);
96 },
97 };
99 install.addListener(listener);
100 install.install();
101 }, "application/x-xpinstall", hash, name, iconURL, version);
103 return deferred.promise;
104 },
105 };