Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 'use strict';
3 const tabs = require('sdk/tabs');
4 const { isPrivate } = require('sdk/private-browsing');
5 const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
6 const { promise: windowPromise, close, focus } = require('sdk/window/helpers');
7 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
9 exports.testOpenTabWithPrivateActiveWindowNoIsPrivateOption = function(assert, done) {
10 let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: true });
12 windowPromise(window, 'load').then(focus).then(function (window) {
13 assert.ok(isPrivate(window), 'new window is private');
15 tabs.open({
16 url: 'about:blank',
17 onOpen: function(tab) {
18 assert.ok(isPrivate(tab), 'new tab is private');
19 assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private');
20 assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same');
22 close(window).then(done).then(null, assert.fail);
23 }
24 })
25 }).then(null, assert.fail);
26 }
28 exports.testOpenTabWithNonPrivateActiveWindowNoIsPrivateOption = function(assert, done) {
29 let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: false });
31 windowPromise(window, 'load').then(focus).then(function (window) {
32 assert.equal(isPrivate(window), false, 'new window is not private');
34 tabs.open({
35 url: 'about:blank',
36 onOpen: function(tab) {
37 assert.equal(isPrivate(tab), false, 'new tab is not private');
38 assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private');
39 assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same');
41 close(window).then(done).then(null, assert.fail);
42 }
43 })
44 }).then(null, assert.fail);
45 }
47 exports.testOpenTabWithPrivateActiveWindowWithIsPrivateOptionTrue = function(assert, done) {
48 let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: true });
50 windowPromise(window, 'load').then(focus).then(function (window) {
51 assert.ok(isPrivate(window), 'new window is private');
53 tabs.open({
54 url: 'about:blank',
55 isPrivate: true,
56 onOpen: function(tab) {
57 assert.ok(isPrivate(tab), 'new tab is private');
58 assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private');
59 assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same');
61 close(window).then(done).then(null, assert.fail);
62 }
63 })
64 }).then(null, assert.fail);
65 }
67 exports.testOpenTabWithNonPrivateActiveWindowWithIsPrivateOptionFalse = function(assert, done) {
68 let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: false });
70 windowPromise(window, 'load').then(focus).then(function (window) {
71 assert.equal(isPrivate(window), false, 'new window is not private');
73 tabs.open({
74 url: 'about:blank',
75 isPrivate: false,
76 onOpen: function(tab) {
77 assert.equal(isPrivate(tab), false, 'new tab is not private');
78 assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private');
79 assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same');
81 close(window).then(done).then(null, assert.fail);
82 }
83 })
84 }).then(null, assert.fail);
85 }