diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-09 06:46:43 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-09 06:46:43 -0500 |
commit | ac46df8daea09899ce30dc8fd70986e258c746bf (patch) | |
tree | 2750d3125fc253fd5b0671e4bd268eff1fd97296 /addon-sdk/source/test/test-windows-common.js | |
parent | 8cecf8d5208f3945b35f879bba3015bb1a11bec6 (diff) | |
download | UXP-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/test-windows-common.js')
-rw-r--r-- | addon-sdk/source/test/test-windows-common.js | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/addon-sdk/source/test/test-windows-common.js b/addon-sdk/source/test/test-windows-common.js deleted file mode 100644 index a4ca6e1a4..000000000 --- a/addon-sdk/source/test/test-windows-common.js +++ /dev/null @@ -1,104 +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 { Loader } = require('sdk/test/loader'); -const { browserWindows } = require('sdk/windows'); -const { isFocused } = require('sdk/window/utils'); -const { viewFor } = require('sdk/view/core'); -const { modelFor } = require('sdk/model/core'); -const { Ci } = require("chrome"); -const { isBrowser, getWindowTitle } = require("sdk/window/utils"); -const { after, cleanUI } = require("sdk/test/utils"); - -// TEST: browserWindows Iterator -exports.testBrowserWindowsIterator = function(assert) { - let activeWindowCount = 0; - let windows = []; - let i = 0; - for (let window of browserWindows) { - if (window === browserWindows.activeWindow) - activeWindowCount++; - - assert.equal(windows.indexOf(window), -1, 'window not already in iterator'); - assert.equal(browserWindows[i++], window, 'browserWindows[x] works'); - windows.push(window); - } - assert.equal(activeWindowCount, 1, 'activeWindow was found in the iterator'); - - i = 0; - for (let j in browserWindows) { - assert.equal(j, i++, 'for (x in browserWindows) works'); - } -}; - -exports.testActiveWindowIsFocused = function(assert) { - assert.ok(isFocused(browserWindows.activeWindow), 'the active window is focused'); -} - -exports.testWindowTabsObject_alt = function(assert, done) { - let window = browserWindows.activeWindow; - window.tabs.open({ - url: 'data:text/html;charset=utf-8,<title>tab 2</title>', - inBackground: true, - onReady: function onReady(tab) { - assert.equal(tab.title, 'tab 2', 'Correct new tab title'); - assert.notEqual(window.tabs.activeTab, tab, 'Correct active tab'); - - // end test - tab.close(done); - } - }); -}; - -// TEST: browserWindows.activeWindow -exports.testWindowActivateMethod_simple = function(assert) { - let window = browserWindows.activeWindow; - let tab = window.tabs.activeTab; - - window.activate(); - - assert.equal(browserWindows.activeWindow, window, - 'Active window is active after window.activate() call'); - assert.equal(window.tabs.activeTab, tab, - 'Active tab is active after window.activate() call'); -}; - - -exports["test getView(window)"] = function*(assert) { - let window = yield new Promise(resolve => { - browserWindows.once("open", resolve); - browserWindows.open({ url: "data:text/html;charset=utf-8,<title>yo</title>" }); - }); - - const view = viewFor(window); - - assert.ok(view instanceof Ci.nsIDOMWindow, "view is a window"); - assert.ok(isBrowser(view), "view is a browser window"); - assert.equal(getWindowTitle(view), window.title, - "window has a right title"); -}; - - -exports["test modelFor(window)"] = function(assert, done) { - browserWindows.once("open", window => { - const view = viewFor(window); - - assert.ok(view instanceof Ci.nsIDOMWindow, "view is a window"); - assert.ok(isBrowser(view), "view is a browser window"); - assert.ok(modelFor(view) === window, "modelFor(browserWindow) is SDK window"); - - window.close(done); - }); - - - browserWindows.open({ url: "data:text/html;charset=utf-8,<title>yo</title>" }); -}; - -after(exports, function*(name, assert) { - assert.pass("cleaning the ui."); - yield cleanUI(); -}); - -require('sdk/test').run(exports); |