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/. */
4 "use strict";
6 const { Loader } = require("sdk/test/loader");
7 const { open, close } = require("sdk/window/helpers");
8 const { browserWindows: windows } = require("sdk/windows");
9 const { isBrowser } = require('sdk/window/utils');
10 const app = require("sdk/system/xul-app");
12 exports["test unload window observer"] = function(assert, done) {
13 // Hacky way to be able to create unloadable modules via makeSandboxedLoader.
14 let loader = Loader(module);
15 let observer = loader.require("sdk/windows/observer").observer;
16 let opened = 0;
17 let closed = 0;
18 let windowsOpen = windows.length;
20 observer.on("open", onOpen);
21 observer.on("close", onClose);
23 // On Fennec, only test that the module does not throw an error
24 if (app.is("Fennec")) {
25 assert.pass("Windows observer did not throw on Fennec");
26 return cleanUp();
27 }
29 // Open window and close it to trigger observers.
30 open().
31 then(close).
32 then(loader.unload).
33 then(open).
34 then(close).
35 then(function() {
36 // Enqueuing asserts to make sure that assertion is not performed early.
37 assert.equal(1, opened, "observer open was called before unload only");
38 assert.equal(windowsOpen + 1, closed, "observer close was called before unload only");
39 }).
40 then(cleanUp, assert.fail);
42 function cleanUp () {
43 observer.removeListener("open", onOpen);
44 observer.removeListener("close", onClose);
45 done();
46 }
48 function onOpen(window) {
49 // Ignoring non-browser windows
50 if (isBrowser(window))
51 opened++;
52 }
53 function onClose(window) {
54 // Ignore non-browser windows & already opened `activeWindow` (unload will
55 // emit close on it even though it is not actually closed).
56 if (isBrowser(window))
57 closed++;
58 }
59 };
61 require("sdk/test").run(exports);