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 /testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js | |
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 'testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js')
-rw-r--r-- | testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js new file mode 100644 index 000000000..5de7794f5 --- /dev/null +++ b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ +'use strict'; + +function isDOMLoaded(browser) { + return ContentTask.spawn(browser, null, function*() { + Assert.equal(content.document.readyState, "complete", + "Browser should be loaded."); + }); +} + +// It checks if calling BrowserTestUtils.browserLoaded() yields +// browser object. +add_task(function*() { + let tab = gBrowser.addTab('http://example.com'); + let browser = tab.linkedBrowser; + yield BrowserTestUtils.browserLoaded(browser); + yield isDOMLoaded(browser); + gBrowser.removeTab(tab); +}); + +// It checks that BrowserTestUtils.browserLoaded() works well with +// promise.all(). +add_task(function*() { + let tabURLs = [ + `http://example.org`, + `http://mochi.test:8888`, + `http://test:80`, + ]; + //Add tabs, get the respective browsers + let browsers = [ + for (u of tabURLs) gBrowser.addTab(u).linkedBrowser + ]; + //wait for promises to settle + yield Promise.all(( + for (b of browsers) BrowserTestUtils.browserLoaded(b) + )); + let expected = 'Expected all promised browsers to have loaded.'; + for (const browser of browsers) { + yield isDOMLoaded(browser); + } + //cleanup + browsers + .map(browser => gBrowser.getTabForBrowser(browser)) + .forEach(tab => gBrowser.removeTab(tab)); +}); |