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.
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 { create: makeFrame } = require("sdk/frame/utils");
7 const { window } = require("sdk/addon/window");
8 const { Loader } = require('sdk/test/loader');
9 const loader = Loader(module);
10 const Worker = loader.require("sdk/content/worker").Worker;
12 exports.testMembranelessMode = function(assert, done) {
14 let url = "data:text/html;charset=utf-8," + encodeURIComponent(
15 '<script>' +
16 'function runTest() {' +
17 ' assert(fuu.bar == 42, "Content-script objects should be accessible to content with' +
18 ' the unsafe-content-script flag on.");' +
19 '}' +
20 '</script>'
21 );
23 let element = makeFrame(window.document, {
24 nodeName: "iframe",
25 type: "content",
26 allowJavascript: true,
27 allowPlugins: true,
28 allowAuth: true,
29 uri: url
30 });
32 element.addEventListener("DOMContentLoaded", onDOMReady, false);
34 function onDOMReady() {
35 let worker = Worker({
36 window: element.contentWindow,
37 contentScript:
38 'new ' + function () {
39 var assert = function assert(v, msg) {
40 self.port.emit("assert", { assertion: v, msg: msg });
41 }
42 var done = function done() {
43 self.port.emit("done");
44 }
45 window.wrappedJSObject.fuu = { bar: 42 };
46 window.wrappedJSObject.assert = assert;
47 window.wrappedJSObject.runTest();
48 done();
49 }
50 });
51 worker.port.on("done", function () {
52 element.parentNode.removeChild(element);
53 done();
54 });
55 worker.port.on("assert", function (data) {
56 assert.ok(data.assertion, data.msg);
57 });
58 }
59 };
61 require("sdk/test/runner").runTestsFromModule(module);