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 'use strict';
3 const { open, focus, close } = require('sdk/window/helpers');
4 const { isPrivate } = require('sdk/private-browsing');
5 const { defer } = require('sdk/core/promise');
6 const { browserWindows: windows } = require('sdk/windows');
8 const BROWSER = 'chrome://browser/content/browser.xul';
10 exports.testRequirePanel = function(assert) {
11 require('sdk/panel');
12 assert.ok('the panel module should not throw an error');
13 };
15 exports.testShowPanelInPrivateWindow = function(assert, done) {
16 let panel = require('sdk/panel').Panel({
17 contentURL: "data:text/html;charset=utf-8,"
18 });
20 assert.ok(windows.length > 0, 'there is at least one open window');
21 for (let window of windows) {
22 assert.equal(isPrivate(window), false, 'open window is private');
23 }
25 testShowPanel(assert, panel).
26 then(makeEmptyPrivateBrowserWindow).
27 then(focus).
28 then(function(window) {
29 assert.equal(isPrivate(window), true, 'opened window is private');
30 assert.pass('private window was focused');
31 return window;
32 }).
33 then(function(window) {
34 let { promise, resolve } = defer();
36 assert.ok(!panel.isShowing, 'the panel is not showing [1]');
38 panel.once('show', function() {
39 assert.ok(panel.isShowing, 'the panel is showing');
41 panel.once('hide', function() {
42 assert.ok(!panel.isShowing, 'the panel is not showing [2]');
44 resolve(window);
45 });
47 panel.hide();
48 });
50 panel.show();
52 return promise;
53 }).
54 then(close).
55 then(done).
56 then(null, assert.fail);
57 };
60 function makeEmptyPrivateBrowserWindow(options) {
61 options = options || {};
62 return open(BROWSER, {
63 features: {
64 chrome: true,
65 toolbar: true,
66 private: true
67 }
68 });
69 }
71 function testShowPanel(assert, panel) {
72 let { promise, resolve } = defer();
73 let shown = false;
75 assert.ok(!panel.isShowing, 'the panel is not showing [1]');
77 panel.once('hide', function() {
78 assert.ok(!panel.isShowing, 'the panel is not showing [2]');
79 assert.ok(shown, 'the panel was shown')
81 resolve(null);
82 });
84 panel.once('show', function() {
85 shown = true;
87 assert.ok(panel.isShowing, 'the panel is showing');
89 panel.hide();
90 });
92 panel.show();
94 return promise;
95 }
97 //Test disabled because of bug 911071
98 module.exports = {}