Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | "use strict"; |
michael@0 | 5 | |
michael@0 | 6 | // Opening new windows in Fennec causes issues |
michael@0 | 7 | module.metadata = { |
michael@0 | 8 | engines: { |
michael@0 | 9 | 'Firefox': '*' |
michael@0 | 10 | } |
michael@0 | 11 | }; |
michael@0 | 12 | |
michael@0 | 13 | const { Loader } = require("sdk/test/loader"); |
michael@0 | 14 | const { open, getMostRecentBrowserWindow, getOuterId } = require("sdk/window/utils"); |
michael@0 | 15 | |
michael@0 | 16 | exports["test browser events"] = function(assert, done) { |
michael@0 | 17 | let loader = Loader(module); |
michael@0 | 18 | let { events } = loader.require("sdk/window/events"); |
michael@0 | 19 | let { on, off } = loader.require("sdk/event/core"); |
michael@0 | 20 | let actual = []; |
michael@0 | 21 | |
michael@0 | 22 | on(events, "data", function handler(e) { |
michael@0 | 23 | actual.push(e); |
michael@0 | 24 | |
michael@0 | 25 | if (e.type === "open") { |
michael@0 | 26 | assert.pass("window open has occured"); |
michael@0 | 27 | } |
michael@0 | 28 | else if (e.type === "DOMContentLoaded") { |
michael@0 | 29 | assert.pass("window DOMContentLoaded has occured"); |
michael@0 | 30 | } |
michael@0 | 31 | else if (e.type === "load") { |
michael@0 | 32 | assert.pass("window load has occured"); |
michael@0 | 33 | window.close(); |
michael@0 | 34 | } |
michael@0 | 35 | else if (e.type === "close") { |
michael@0 | 36 | // confirm the ordering of events |
michael@0 | 37 | let [ open, ready, load, close ] = actual; |
michael@0 | 38 | assert.equal(open.type, "open") |
michael@0 | 39 | assert.equal(open.target, window, "window is open") |
michael@0 | 40 | |
michael@0 | 41 | assert.equal(ready.type, "DOMContentLoaded") |
michael@0 | 42 | assert.equal(ready.target, window, "window ready") |
michael@0 | 43 | |
michael@0 | 44 | assert.equal(load.type, "load") |
michael@0 | 45 | assert.equal(load.target, window, "window load") |
michael@0 | 46 | |
michael@0 | 47 | assert.equal(close.type, "close") |
michael@0 | 48 | assert.equal(close.target, window, "window load") |
michael@0 | 49 | |
michael@0 | 50 | // Note: If window is closed right after this GC won't have time |
michael@0 | 51 | // to claim loader and there for this listener. It's better to remove |
michael@0 | 52 | // remove listener here to avoid race conditions. |
michael@0 | 53 | off(events, "data", handler); |
michael@0 | 54 | loader.unload(); |
michael@0 | 55 | done(); |
michael@0 | 56 | } |
michael@0 | 57 | }); |
michael@0 | 58 | |
michael@0 | 59 | // Open window and close it to trigger observers. |
michael@0 | 60 | let window = open(); |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | require("sdk/test").run(exports); |