summaryrefslogtreecommitdiffstats
path: root/addon-sdk/source/test/private-browsing
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
commitac46df8daea09899ce30dc8fd70986e258c746bf (patch)
tree2750d3125fc253fd5b0671e4bd268eff1fd97296 /addon-sdk/source/test/private-browsing
parent8cecf8d5208f3945b35f879bba3015bb1a11bec6 (diff)
downloadUXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.gz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.lz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.xz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.zip
Move Add-on SDK source to toolkit/jetpack
Diffstat (limited to 'addon-sdk/source/test/private-browsing')
-rw-r--r--addon-sdk/source/test/private-browsing/helper.js58
-rw-r--r--addon-sdk/source/test/private-browsing/tabs.js25
-rw-r--r--addon-sdk/source/test/private-browsing/windows.js115
3 files changed, 0 insertions, 198 deletions
diff --git a/addon-sdk/source/test/private-browsing/helper.js b/addon-sdk/source/test/private-browsing/helper.js
deleted file mode 100644
index 4a400b95b..000000000
--- a/addon-sdk/source/test/private-browsing/helper.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-'use strict';
-
-const xulApp = require("sdk/system/xul-app");
-const { open: openWindow, getMostRecentBrowserWindow } = require('sdk/window/utils');
-const { openTab, getTabContentWindow, getActiveTab, setTabURL, closeTab } = require('sdk/tabs/utils');
-const promise = require("sdk/core/promise");
-const windowHelpers = require('sdk/window/helpers');
-const events = require("sdk/system/events");
-
-exports.openWebpage = function openWebpage(url, enablePrivate) {
- if (xulApp.is("Fennec")) {
- let chromeWindow = getMostRecentBrowserWindow();
- let rawTab = openTab(chromeWindow, url, {
- isPrivate: enablePrivate
- });
-
- return {
- ready: promise.resolve(getTabContentWindow(rawTab)),
- close: function () {
- closeTab(rawTab);
- // Returns a resolved promise as there is no need to wait
- return promise.resolve();
- }
- };
- }
- else {
- let win = openWindow(null, {
- features: {
- private: enablePrivate
- }
- });
- let deferred = promise.defer();
-
- // Wait for delayed startup code to be executed, in order to ensure
- // that the window is really ready
- events.on("browser-delayed-startup-finished", function onReady({subject}) {
- if (subject == win) {
- events.off("browser-delayed-startup-finished", onReady);
- deferred.resolve(win);
-
- let rawTab = getActiveTab(win);
- setTabURL(rawTab, url);
- deferred.resolve(getTabContentWindow(rawTab));
- }
- }, true);
-
- return {
- ready: deferred.promise,
- close: function () {
- return windowHelpers.close(win);
- }
- };
- }
- return null;
-}
diff --git a/addon-sdk/source/test/private-browsing/tabs.js b/addon-sdk/source/test/private-browsing/tabs.js
deleted file mode 100644
index 8564f0735..000000000
--- a/addon-sdk/source/test/private-browsing/tabs.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-'use strict';
-
-const { Ci } = require('chrome');
-const { openTab, closeTab } = require('sdk/tabs/utils');
-const { browserWindows } = require('sdk/windows');
-const { isPrivate } = require('sdk/private-browsing');
-
-exports.testIsPrivateOnTab = function(assert) {
- let window = browserWindows.activeWindow;
- assert.ok(!isPrivate(chromeWindow), 'the top level window is not private');
-
- let rawTab = openTab(chromeWindow, 'data:text/html,<h1>Hi!</h1>', {
- isPrivate: true
- });
-
- // test that the tab is private
- assert.ok(rawTab.browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing);
- assert.ok(isPrivate(rawTab.browser.contentWindow));
- assert.ok(isPrivate(rawTab.browser));
-
- closeTab(rawTab);
-};
diff --git a/addon-sdk/source/test/private-browsing/windows.js b/addon-sdk/source/test/private-browsing/windows.js
deleted file mode 100644
index e6f9c53b5..000000000
--- a/addon-sdk/source/test/private-browsing/windows.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-'use strict';
-
-const { onFocus, openDialog, open } = require('sdk/window/utils');
-const { open: openPromise, close, focus, promise } = require('sdk/window/helpers');
-const { isPrivate } = require('sdk/private-browsing');
-const { getMode } = require('sdk/private-browsing/utils');
-const { browserWindows: windows } = require('sdk/windows');
-const { defer } = require('sdk/core/promise');
-const tabs = require('sdk/tabs');
-const { getMostRecentBrowserWindow } = require('sdk/window/utils');
-const { cleanUI } = require("sdk/test/utils");
-
-// test openDialog() from window/utils with private option
-// test isActive state in pwpb case
-// test isPrivate on ChromeWindow
-exports.testPerWindowPrivateBrowsingGetter = function*(assert) {
- let win = openDialog({ private: true });
-
- yield promise(win, 'DOMContentLoaded');
-
- assert.equal(getMode(win), true, 'Newly opened window is in PB mode');
- assert.ok(isPrivate(win), 'isPrivate(window) is true');
-
- yield close(win);
-}
-
-// test open() from window/utils with private feature
-// test isActive state in pwpb case
-// test isPrivate on ChromeWindow
-exports.testPerWindowPrivateBrowsingGetter = function*(assert) {
- let win = open('chrome://browser/content/browser.xul', {
- features: {
- private: true
- }
- });
-
- yield promise(win, 'DOMContentLoaded');
- assert.equal(getMode(win), true, 'Newly opened window is in PB mode');
- assert.ok(isPrivate(win), 'isPrivate(window) is true');
- yield close(win)
-}
-
-exports.testIsPrivateOnWindowOpen = function*(assert) {
- let window = yield new Promise(resolve => {
- windows.open({
- isPrivate: true,
- onOpen: resolve
- });
- });
-
- assert.equal(isPrivate(window), false, 'isPrivate for a window is true when it should be');
- assert.equal(isPrivate(window.tabs[0]), false, 'isPrivate for a tab is false when it should be');
-
- yield cleanUI();
-}
-
-exports.testIsPrivateOnWindowOpenFromPrivate = function(assert, done) {
- // open a private window
- openPromise(null, {
- features: {
- private: true,
- chrome: true,
- titlebar: true,
- toolbar: true
- }
- }).then(focus).then(function(window) {
- let { promise, resolve } = defer();
-
- assert.equal(isPrivate(window), true, 'the only open window is private');
-
- windows.open({
- url: 'about:blank',
- onOpen: function(w) {
- assert.equal(isPrivate(w), false, 'new test window is not private');
- w.close(() => resolve(window));
- }
- });
-
- return promise;
- }).then(close).
- then(done, assert.fail);
-};
-
-exports.testOpenTabWithPrivateWindow = function*(assert) {
- let window = getMostRecentBrowserWindow().OpenBrowserWindow({ private: true });
-
- assert.pass("loading new private window");
-
- yield promise(window, 'load').then(focus);
-
- assert.equal(isPrivate(window), true, 'the focused window is private');
-
- yield new Promise(resolve => tabs.open({
- url: 'about:blank',
- onOpen: (tab) => {
- assert.equal(isPrivate(tab), false, 'the opened tab is not private');
- tab.close(resolve);
- }
- }));
-
- yield close(window);
-};
-
-exports.testIsPrivateOnWindowOff = function(assert, done) {
- windows.open({
- onOpen: function(window) {
- assert.equal(isPrivate(window), false, 'isPrivate for a window is false when it should be');
- assert.equal(isPrivate(window.tabs[0]), false, 'isPrivate for a tab is false when it should be');
- window.close(done);
- }
- })
-}