From 11219745bf3cba650c1008eb38d1fc9e9159095f Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Sun, 18 Sep 2016 21:48:00 -0400 Subject: [PATCH] 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 --- .../browser_browserLoaded_content_loaded.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js index 90a9321215fc..73661f96cf37 100644 --- a/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js +++ b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js @@ -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))