Bug 1270704 - Fix intermittent dead CPOW failure in browser_browserLoaded_content_loaded.js. r=mconley
authorMarcos Caceres <marcos@marcosc.com>
Fri, 16 Sep 2016 01:44:00 -0400
changeset 355613 ffb62c341a4411407804e5dea24e406eb17c7028
parent 355612 41d0da5ec5e8e351a23014b7a90fc77e7d84cd65
child 355614 5471f6af44ac807761a1ca0f3c786a37e1a045e7
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1270704
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1270704 - Fix intermittent dead CPOW failure in browser_browserLoaded_content_loaded.js. r=mconley
testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
--- a/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
+++ b/testing/mochitest/tests/browser/browser_browserLoaded_content_loaded.js
@@ -1,24 +1,26 @@
 /* Any copyright is dedicated to the Public Domain.
  * 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
 // browser object.
 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);
 });
 
 // It checks that BrowserTestUtils.browserLoaded() works well with
 // promise.all().
 add_task(function*() {
   let tabURLs = [
     `http://example.org`,
@@ -29,14 +31,16 @@ add_task(function*() {
   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.';
-  Assert.ok(browsers.every(isDOMLoaded), expected);
+  for (const browser of browsers) {
+    yield isDOMLoaded(browser);
+  }
   //cleanup
   browsers
     .map(browser => gBrowser.getTabForBrowser(browser))
     .forEach(tab => gBrowser.removeTab(tab));
 });