Bug 1270704 - Fix intermittent dead CPOW failure in browser_browserLoaded_content_loaded.js. r=mconley, a=test-only
☠☠ backed out by c174d0c31953 ☠ ☠
authorMarcos Caceres <marcos@marcosc.com>
Fri, 16 Sep 2016 01:44:00 -0400
changeset 348218 c1c3b1e2bf94289422620f27e546a42091f01f98
parent 348217 93266904a199ad4d2cb4ee36d0fb15b00fdc61d8
child 348219 d2dfb7d2fe1a0d87ca1f5dfff6114e9b9327c9de
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, test-only
bugs1270704
milestone50.0a2
Bug 1270704 - Fix intermittent dead CPOW failure in browser_browserLoaded_content_loaded.js. r=mconley, a=test-only
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));
 });