Bug 1270704 - Fix intermittent dead CPOW failure in browser_browserLoaded_content_loaded.js. r=mconley, a=test-only

--HG--
extra : source : ffb62c341a4411407804e5dea24e406eb17c7028
extra : intermediate-source : c1c3b1e2bf94289422620f27e546a42091f01f98
extra : histedit_source : 1a21f91dc5e0fae6e8b4a97571cc98fafa06e2b7%2Cbedb6ab3bd200276ce3c250fcdccd9dc9bb7abcc
This commit is contained in:
Marcos Caceres 2016-09-18 21:48:00 -04:00
Родитель 81291461d7
Коммит 11219745bf
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -2,9 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
// Check if the browser has loaded by checking ready state of the DOM.
function isDOMLoaded(aBrowser) {
return aBrowser.contentWindowAsCPOW.document.readyState === 'complete';
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
@ -13,7 +15,7 @@ add_task(function*() {
let tab = gBrowser.addTab('http://example.com');
let browser = tab.linkedBrowser;
yield BrowserTestUtils.browserLoaded(browser);
Assert.ok(isDOMLoaded(browser), 'browser', 'Expect browser to have loaded.');
yield isDOMLoaded(browser);
gBrowser.removeTab(tab);
});
@ -34,7 +36,9 @@ add_task(function*() {
for (b of browsers) BrowserTestUtils.browserLoaded(b)
));
let expected = 'Expected all promised browsers to have loaded.';
Assert.ok(browsers.every(isDOMLoaded), expected);
for (var browser of browsers) {
yield isDOMLoaded(browser);
}
//cleanup
browsers
.map(browser => gBrowser.getTabForBrowser(browser))