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 | const { Cu } = require('chrome'); |
michael@0 | 7 | const sp = require('sdk/simple-prefs'); |
michael@0 | 8 | const app = require('sdk/system/xul-app'); |
michael@0 | 9 | const self = require('sdk/self'); |
michael@0 | 10 | const tabs = require('sdk/tabs'); |
michael@0 | 11 | const { preferencesBranch } = require('sdk/self'); |
michael@0 | 12 | |
michael@0 | 13 | const { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm', {}); |
michael@0 | 14 | |
michael@0 | 15 | // Once Bug 903018 is resolved, just move the application testing to |
michael@0 | 16 | // module.metadata.engines |
michael@0 | 17 | // |
michael@0 | 18 | // This should work in Fennec, needs to be refactored to work, via bug 979645 |
michael@0 | 19 | if (app.is('Firefox')) { |
michael@0 | 20 | exports.testAOMLocalization = function(assert, done) { |
michael@0 | 21 | tabs.open({ |
michael@0 | 22 | url: 'about:addons', |
michael@0 | 23 | onReady: function(tab) { |
michael@0 | 24 | tab.attach({ |
michael@0 | 25 | contentScriptWhen: 'end', |
michael@0 | 26 | contentScript: 'function onLoad() {\n' + |
michael@0 | 27 | 'unsafeWindow.removeEventListener("load", onLoad, false);\n' + |
michael@0 | 28 | 'AddonManager.getAddonByID("' + self.id + '", function(aAddon) {\n' + |
michael@0 | 29 | 'unsafeWindow.gViewController.viewObjects.detail.node.addEventListener("ViewChanged", function whenViewChanges() {\n' + |
michael@0 | 30 | 'unsafeWindow.gViewController.viewObjects.detail.node.removeEventListener("ViewChanged", whenViewChanges, false);\n' + |
michael@0 | 31 | 'setTimeout(function() {\n' + // TODO: figure out why this is necessary.. |
michael@0 | 32 | 'self.postMessage({\n' + |
michael@0 | 33 | 'somePreference: getAttributes(unsafeWindow.document.querySelector("setting[data-jetpack-id=\'' + self.id + '\']"))\n' + |
michael@0 | 34 | '});\n' + |
michael@0 | 35 | '}, 250);\n' + |
michael@0 | 36 | '}, false);\n' + |
michael@0 | 37 | 'unsafeWindow.gViewController.commands.cmd_showItemDetails.doCommand(aAddon, true);\n' + |
michael@0 | 38 | '});\n' + |
michael@0 | 39 | 'function getAttributes(ele) {\n' + |
michael@0 | 40 | 'if (!ele) return {};\n' + |
michael@0 | 41 | 'return {\n' + |
michael@0 | 42 | 'title: ele.getAttribute("title")\n' + |
michael@0 | 43 | '}\n' + |
michael@0 | 44 | '}\n' + |
michael@0 | 45 | '}\n' + |
michael@0 | 46 | // Wait for the load event ? |
michael@0 | 47 | 'if (document.readyState == "complete") {\n' + |
michael@0 | 48 | 'onLoad()\n' + |
michael@0 | 49 | '} else {\n' + |
michael@0 | 50 | 'unsafeWindow.addEventListener("load", onLoad, false);\n' + |
michael@0 | 51 | '}\n', |
michael@0 | 52 | onMessage: function(msg) { |
michael@0 | 53 | // test somePreference |
michael@0 | 54 | assert.equal(msg.somePreference.title, 'A', 'somePreference title is correct'); |
michael@0 | 55 | tab.close(done); |
michael@0 | 56 | } |
michael@0 | 57 | }); |
michael@0 | 58 | } |
michael@0 | 59 | }); |
michael@0 | 60 | } |
michael@0 | 61 | } else { |
michael@0 | 62 | exports['test unsupported'] = (assert) => assert.pass('This test is unsupported.'); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | require('sdk/test/runner').runTestsFromModule(module); |