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 { getTabs } = require('sdk/tabs/utils');
4 const { isGlobalPBSupported, isWindowPBSupported, isTabPBSupported } = require('sdk/private-browsing/utils');
5 const { browserWindows } = require('sdk/windows');
6 const tabs = require('sdk/tabs');
7 const { pb } = require('./private-browsing/helper');
8 const { isPrivate } = require('sdk/private-browsing');
9 const { openTab, closeTab, getTabContentWindow, getOwnerWindow } = require('sdk/tabs/utils');
10 const { open, close } = require('sdk/window/helpers');
11 const { windows } = require('sdk/window/utils');
12 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
13 const { fromIterator } = require('sdk/util/array');
15 if (isWindowPBSupported) {
16 exports.testGetTabs = function(assert, done) {
17 let tabCount = getTabs().length;
18 let windowCount = browserWindows.length;
20 open(null, {
21 features: {
22 private: true,
23 toolbar: true,
24 chrome: true
25 }
26 }).then(function(window) {
27 assert.ok(isPrivate(window), 'new tab is private');
29 assert.equal(getTabs().length, tabCount, 'there are no new tabs found');
30 getTabs().forEach(function(tab) {
31 assert.equal(isPrivate(tab), false, 'all found tabs are not private');
32 assert.equal(isPrivate(getOwnerWindow(tab)), false, 'all found tabs are not private');
33 assert.equal(isPrivate(getTabContentWindow(tab)), false, 'all found tabs are not private');
34 });
36 assert.equal(browserWindows.length, windowCount, 'there are no new windows found');
37 fromIterator(browserWindows).forEach(function(window) {
38 assert.equal(isPrivate(window), false, 'all found windows are not private');
39 });
41 assert.equal(windows(null, {includePrivate: true}).length, 2, 'there are really two windows');
43 close(window).then(done);
44 });
45 };
46 }
47 else if (isTabPBSupported) {
48 exports.testGetTabs = function(assert, done) {
49 let startTabCount = getTabs().length;
50 let tab = openTab(getMostRecentBrowserWindow(), 'about:blank', {
51 isPrivate: true
52 });
54 assert.ok(isPrivate(getTabContentWindow(tab)), 'new tab is private');
55 let utils_tabs = getTabs();
56 assert.equal(utils_tabs.length, startTabCount + 1,
57 'there are two tabs found');
58 assert.equal(utils_tabs[utils_tabs.length-1], tab,
59 'the last tab is the opened tab');
60 assert.equal(browserWindows.length, 1, 'there is only one window');
61 closeTab(tab);
63 done();
64 };
65 }
67 require('test').run(exports);