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 | |
michael@0 | 5 | "use strict" |
michael@0 | 6 | |
michael@0 | 7 | const { LoaderWithHookedConsole } = require("sdk/test/loader"); |
michael@0 | 8 | |
michael@0 | 9 | exports["test LoaderWithHookedConsole"] = function (assert) { |
michael@0 | 10 | let count = 0; |
michael@0 | 11 | function onMessage(type, message) { |
michael@0 | 12 | switch (count++) { |
michael@0 | 13 | case 0: |
michael@0 | 14 | assert.equal(type, "log", "got log type"); |
michael@0 | 15 | assert.equal(message, "1st", "got log msg"); |
michael@0 | 16 | break; |
michael@0 | 17 | case 1: |
michael@0 | 18 | assert.equal(type, "error", "got error type"); |
michael@0 | 19 | assert.equal(message, "2nd", "got error msg"); |
michael@0 | 20 | break; |
michael@0 | 21 | case 2: |
michael@0 | 22 | assert.equal(type, "warn", "got warn type"); |
michael@0 | 23 | assert.equal(message, "3rd", "got warn msg"); |
michael@0 | 24 | break; |
michael@0 | 25 | case 3: |
michael@0 | 26 | assert.equal(type, "info", "got info type"); |
michael@0 | 27 | assert.equal(message, "4th", "got info msg"); |
michael@0 | 28 | break; |
michael@0 | 29 | case 4: |
michael@0 | 30 | assert.equal(type, "debug", "got debug type"); |
michael@0 | 31 | assert.equal(message, "5th", "got debug msg"); |
michael@0 | 32 | break; |
michael@0 | 33 | case 5: |
michael@0 | 34 | assert.equal(type, "exception", "got exception type"); |
michael@0 | 35 | assert.equal(message, "6th", "got exception msg"); |
michael@0 | 36 | break; |
michael@0 | 37 | default: |
michael@0 | 38 | assert.fail("Got unexception message: " + i); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | let { loader, messages } = LoaderWithHookedConsole(module, onMessage); |
michael@0 | 43 | let console = loader.globals.console; |
michael@0 | 44 | console.log("1st"); |
michael@0 | 45 | console.error("2nd"); |
michael@0 | 46 | console.warn("3rd"); |
michael@0 | 47 | console.info("4th"); |
michael@0 | 48 | console.debug("5th"); |
michael@0 | 49 | console.exception("6th"); |
michael@0 | 50 | assert.equal(messages.length, 6, "Got all console messages"); |
michael@0 | 51 | assert.deepEqual(messages[0], {type: "log", msg: "1st", innerID: null}, "Got log"); |
michael@0 | 52 | assert.deepEqual(messages[1], {type: "error", msg: "2nd", innerID: null}, "Got error"); |
michael@0 | 53 | assert.deepEqual(messages[2], {type: "warn", msg: "3rd", innerID: null}, "Got warn"); |
michael@0 | 54 | assert.deepEqual(messages[3], {type: "info", msg: "4th", innerID: null}, "Got info"); |
michael@0 | 55 | assert.deepEqual(messages[4], {type: "debug", msg: "5th", innerID: null}, "Got debug"); |
michael@0 | 56 | assert.deepEqual(messages[5], {type: "exception", msg: "6th", innerID: null}, "Got exception"); |
michael@0 | 57 | assert.equal(count, 6, "Called for all messages"); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | require("sdk/test").run(exports); |