diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /addon-sdk/source/test/addons/e10s | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'addon-sdk/source/test/addons/e10s')
-rw-r--r-- | addon-sdk/source/test/addons/e10s/lib/main.js | 65 | ||||
-rw-r--r-- | addon-sdk/source/test/addons/e10s/package.json | 10 |
2 files changed, 75 insertions, 0 deletions
diff --git a/addon-sdk/source/test/addons/e10s/lib/main.js b/addon-sdk/source/test/addons/e10s/lib/main.js new file mode 100644 index 000000000..1eee511c3 --- /dev/null +++ b/addon-sdk/source/test/addons/e10s/lib/main.js @@ -0,0 +1,65 @@ +/* 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 { getMostRecentBrowserWindow, isBrowser } = require('sdk/window/utils'); +const { promise: windowPromise, close, focus } = require('sdk/window/helpers'); +const { openTab, closeTab, getBrowserForTab } = require('sdk/tabs/utils'); +const { WindowTracker } = require('sdk/deprecated/window-utils'); +const { version, platform } = require('sdk/system'); +const { when } = require('sdk/system/unload'); +const tabs = require('sdk/tabs'); + +const SKIPPING_TESTS = { + "test skip": (assert) => assert.pass("nothing to test here") +}; + +exports.testTabIsRemote = function(assert, done) { + const url = 'data:text/html,test-tab-is-remote'; + let tab = openTab(getMostRecentBrowserWindow(), url); + assert.ok(tab.linkedBrowser.isRemoteBrowser, "The new tab should be remote"); + + // can't simply close a remote tab before it is loaded, bug 1006043 + let mm = getBrowserForTab(tab).messageManager; + mm.addMessageListener('7', function listener() { + mm.removeMessageListener('7', listener); + tabs.once('close', done); + closeTab(tab); + }) + mm.loadFrameScript('data:,sendAsyncMessage("7")', true); +} + +// run e10s tests only on builds from trunk, fx-team, Nightly.. +if (!version.endsWith('a1')) { + module.exports = {}; +} + +function replaceWindow(remote) { + let next = null; + let old = getMostRecentBrowserWindow(); + let promise = new Promise(resolve => { + let tracker = WindowTracker({ + onTrack: window => { + if (window !== next) + return; + resolve(window); + tracker.unload(); + } + }); + }) + next = old.OpenBrowserWindow({ remote }); + return promise.then(focus).then(_ => close(old)); +} + +// bug 1054482 - e10s test addons time out on linux +if (platform === 'linux') { + module.exports = SKIPPING_TESTS; + require('sdk/test/runner').runTestsFromModule(module); +} +else { + replaceWindow(true).then(_ => + require('sdk/test/runner').runTestsFromModule(module)); + + when(_ => replaceWindow(false)); +} diff --git a/addon-sdk/source/test/addons/e10s/package.json b/addon-sdk/source/test/addons/e10s/package.json new file mode 100644 index 000000000..93039749a --- /dev/null +++ b/addon-sdk/source/test/addons/e10s/package.json @@ -0,0 +1,10 @@ +{ + "name": "e10s", + "title": "e10s", + "id": "jid1-DYaXFHAPlHwbgw@jetpack", + "description": "a basic e10s test add-on", + "author": "Tomislav Jovanovic", + "license": "MPL-2.0", + "version": "0.1.0", + "main": "./lib/main.js" +} |