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.
michael@0 | 1 | 'use strict'; |
michael@0 | 2 | |
michael@0 | 3 | const tabs = require('sdk/tabs'); |
michael@0 | 4 | const { isPrivate } = require('sdk/private-browsing'); |
michael@0 | 5 | const { getOwnerWindow } = require('sdk/private-browsing/window/utils'); |
michael@0 | 6 | const { promise: windowPromise, close, focus } = require('sdk/window/helpers'); |
michael@0 | 7 | const { getMostRecentBrowserWindow } = require('sdk/window/utils'); |
michael@0 | 8 | |
michael@0 | 9 | exports.testOpenTabWithPrivateActiveWindowNoIsPrivateOption = function(assert, done) { |
michael@0 | 10 | let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: true }); |
michael@0 | 11 | |
michael@0 | 12 | windowPromise(window, 'load').then(focus).then(function (window) { |
michael@0 | 13 | assert.ok(isPrivate(window), 'new window is private'); |
michael@0 | 14 | |
michael@0 | 15 | tabs.open({ |
michael@0 | 16 | url: 'about:blank', |
michael@0 | 17 | onOpen: function(tab) { |
michael@0 | 18 | assert.ok(isPrivate(tab), 'new tab is private'); |
michael@0 | 19 | assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private'); |
michael@0 | 20 | assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same'); |
michael@0 | 21 | |
michael@0 | 22 | close(window).then(done).then(null, assert.fail); |
michael@0 | 23 | } |
michael@0 | 24 | }) |
michael@0 | 25 | }).then(null, assert.fail); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | exports.testOpenTabWithNonPrivateActiveWindowNoIsPrivateOption = function(assert, done) { |
michael@0 | 29 | let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: false }); |
michael@0 | 30 | |
michael@0 | 31 | windowPromise(window, 'load').then(focus).then(function (window) { |
michael@0 | 32 | assert.equal(isPrivate(window), false, 'new window is not private'); |
michael@0 | 33 | |
michael@0 | 34 | tabs.open({ |
michael@0 | 35 | url: 'about:blank', |
michael@0 | 36 | onOpen: function(tab) { |
michael@0 | 37 | assert.equal(isPrivate(tab), false, 'new tab is not private'); |
michael@0 | 38 | assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private'); |
michael@0 | 39 | assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same'); |
michael@0 | 40 | |
michael@0 | 41 | close(window).then(done).then(null, assert.fail); |
michael@0 | 42 | } |
michael@0 | 43 | }) |
michael@0 | 44 | }).then(null, assert.fail); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | exports.testOpenTabWithPrivateActiveWindowWithIsPrivateOptionTrue = function(assert, done) { |
michael@0 | 48 | let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: true }); |
michael@0 | 49 | |
michael@0 | 50 | windowPromise(window, 'load').then(focus).then(function (window) { |
michael@0 | 51 | assert.ok(isPrivate(window), 'new window is private'); |
michael@0 | 52 | |
michael@0 | 53 | tabs.open({ |
michael@0 | 54 | url: 'about:blank', |
michael@0 | 55 | isPrivate: true, |
michael@0 | 56 | onOpen: function(tab) { |
michael@0 | 57 | assert.ok(isPrivate(tab), 'new tab is private'); |
michael@0 | 58 | assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private'); |
michael@0 | 59 | assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same'); |
michael@0 | 60 | |
michael@0 | 61 | close(window).then(done).then(null, assert.fail); |
michael@0 | 62 | } |
michael@0 | 63 | }) |
michael@0 | 64 | }).then(null, assert.fail); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | exports.testOpenTabWithNonPrivateActiveWindowWithIsPrivateOptionFalse = function(assert, done) { |
michael@0 | 68 | let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: false }); |
michael@0 | 69 | |
michael@0 | 70 | windowPromise(window, 'load').then(focus).then(function (window) { |
michael@0 | 71 | assert.equal(isPrivate(window), false, 'new window is not private'); |
michael@0 | 72 | |
michael@0 | 73 | tabs.open({ |
michael@0 | 74 | url: 'about:blank', |
michael@0 | 75 | isPrivate: false, |
michael@0 | 76 | onOpen: function(tab) { |
michael@0 | 77 | assert.equal(isPrivate(tab), false, 'new tab is not private'); |
michael@0 | 78 | assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private'); |
michael@0 | 79 | assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same'); |
michael@0 | 80 | |
michael@0 | 81 | close(window).then(done).then(null, assert.fail); |
michael@0 | 82 | } |
michael@0 | 83 | }) |
michael@0 | 84 | }).then(null, assert.fail); |
michael@0 | 85 | } |