diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
commit | 37d5300335d81cecbecc99812747a657588c63eb (patch) | |
tree | 765efa3b6a56bb715d9813a8697473e120436278 /addon-sdk/source/test/addons/private-browsing-supported/test-panel.js | |
parent | b2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff) | |
parent | 4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff) | |
download | UXP-37d5300335d81cecbecc99812747a657588c63eb.tar UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz UXP-37d5300335d81cecbecc99812747a657588c63eb.zip |
Merge branch 'ext-work'
Diffstat (limited to 'addon-sdk/source/test/addons/private-browsing-supported/test-panel.js')
-rw-r--r-- | addon-sdk/source/test/addons/private-browsing-supported/test-panel.js | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/addon-sdk/source/test/addons/private-browsing-supported/test-panel.js b/addon-sdk/source/test/addons/private-browsing-supported/test-panel.js deleted file mode 100644 index 1ba3e9554..000000000 --- a/addon-sdk/source/test/addons/private-browsing-supported/test-panel.js +++ /dev/null @@ -1,99 +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 { open, focus, close } = require('sdk/window/helpers'); -const { isPrivate } = require('sdk/private-browsing'); -const { defer } = require('sdk/core/promise'); -const { browserWindows: windows } = require('sdk/windows'); -const { getInnerId, getMostRecentBrowserWindow } = require('sdk/window/utils'); -const { getActiveView } = require('sdk/view/core'); - -const BROWSER = 'chrome://browser/content/browser.xul'; - -exports.testRequirePanel = function(assert) { - require('sdk/panel'); - assert.ok('the panel module should not throw an error'); -}; - -exports.testShowPanelInPrivateWindow = function(assert, done) { - let panel = require('sdk/panel').Panel({ - contentURL: "data:text/html;charset=utf-8,I'm a leaf on the wind" - }); - - assert.ok(windows.length > 0, 'there is at least one open window'); - for (let window of windows) { - assert.equal(isPrivate(window), false, 'open window is private'); - } - - let panelView = getActiveView(panel); - let expectedWindowId = getInnerId(panelView.backgroundFrame.contentWindow); - - function checkPanelFrame() { - let iframe = panelView.firstChild; - - assert.equal(panelView.viewFrame, iframe, 'panel has the correct viewFrame value'); - - let windowId = getInnerId(iframe.contentWindow); - - assert.equal(windowId, expectedWindowId, 'panel has the correct window visible'); - - assert.equal(iframe.contentDocument.body.textContent, - "I'm a leaf on the wind", - 'the panel has the expected content'); - } - - function testPanel(window) { - let { promise, resolve } = defer(); - - assert.ok(!panel.isShowing, 'the panel is not showing [1]'); - - panel.once('show', function() { - assert.ok(panel.isShowing, 'the panel is showing'); - - checkPanelFrame(); - - panel.once('hide', function() { - assert.ok(!panel.isShowing, 'the panel is not showing [2]'); - - resolve(window); - }); - - panel.hide(); - }); - - panel.show(); - - return promise; - }; - - let initialWindow = getMostRecentBrowserWindow(); - - testPanel(initialWindow). - then(makeEmptyPrivateBrowserWindow). - then(focus). - then(function(window) { - assert.equal(isPrivate(window), true, 'opened window is private'); - assert.pass('private window was focused'); - return window; - }). - then(testPanel). - then(close). - then(() => focus(initialWindow)). - then(testPanel). - then(done). - then(null, assert.fail); -}; - - -function makeEmptyPrivateBrowserWindow(options) { - options = options || {}; - return open(BROWSER, { - features: { - chrome: true, - toolbar: true, - private: true - } - }); -} |