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/. */
5 "use strict";
7 const { on, once, off, emit, count } = require("sdk/event/core");
9 function scenario(setup) {
10 return function(unit) {
11 return function(assert) {
12 let actual = [];
13 let input = {};
14 unit(input, function(output, events, expected, message) {
15 let result = setup(output, expected, actual);
17 events.forEach(function(event) emit(input, "data", event));
19 assert.deepEqual(actual, result, message);
20 });
21 }
22 }
23 }
25 exports.emits = scenario(function(output, expected, actual) {
26 on(output, "data", function(data) actual.push(this, data));
28 return expected.reduce(function($$, $) $$.concat(output, $), []);
29 });
31 exports.registerOnce = scenario(function(output, expected, actual) {
32 function listener(data) actual.push(data);
33 on(output, "data", listener);
34 on(output, "data", listener);
35 on(output, "data", listener);
37 return expected;
38 });
40 exports.ignoreNew = scenario(function(output, expected, actual) {
41 on(output, "data", function(data) {
42 actual.push(data + "#1");
43 on(output, "data", function(data) {
44 actual.push(data + "#2");
45 });
46 });
48 return expected.map(function($) $ + "#1");
49 });
51 exports.FIFO = scenario(function(target, expected, actual) {
52 on(target, "data", function($) actual.push($ + "#1"));
53 on(target, "data", function($) actual.push($ + "#2"));
54 on(target, "data", function($) actual.push($ + "#3"));
56 return expected.reduce(function(result, value) {
57 return result.concat(value + "#1", value + "#2", value + "#3");
58 }, []);
59 });