Bug 1153457 - Remove CPOWs from browser_RemoteWebNavigation.js. r=mconley
☠☠ backed out by 13758ac39b56 ☠ ☠
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 24 Feb 2017 14:09:36 -0800
changeset 394175 e72421387bb835f7959217fe680dcb3925fee381
parent 394174 a9871ce99a2a9bb02864bd9d695543fae69b2f24
child 394176 41f3d9a17672a2569e79ee96b44143a58d13098e
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1153457
milestone54.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 1153457 - Remove CPOWs from browser_RemoteWebNavigation.js. r=mconley MozReview-Commit-ID: 9f8nCsATErR
toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
--- a/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
@@ -1,27 +1,19 @@
 var { interfaces: Ci, classes: Cc, utils: Cu, results: Cr } = Components;
 
 const DUMMY1 = "http://example.com/browser/toolkit/modules/tests/browser/dummy_page.html";
 const DUMMY2 = "http://example.org/browser/toolkit/modules/tests/browser/dummy_page.html"
 
 function waitForLoad(browser = gBrowser.selectedBrowser) {
-  return new Promise(resolve => {
-    browser.addEventListener("load", function() {
-      resolve();
-    }, {capture: true, once: true});
-  });
+  return BrowserTestUtils.browserLoaded(browser);
 }
 
 function waitForPageShow(browser = gBrowser.selectedBrowser) {
-  return new Promise(resolve => {
-    browser.addEventListener("pageshow", function() {
-      resolve();
-    }, {capture: true, once: true});
-  });
+  return BrowserTestUtils.waitForContentEvent(browser, "pageshow", true);
 }
 
 function makeURI(url) {
   return Cc["@mozilla.org/network/io-service;1"].
          getService(Ci.nsIIOService).
          newURI(url);
 }
 
@@ -30,93 +22,109 @@ add_task(function* test_referrer() {
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 makeURI(DUMMY2),
                                 null, null);
   yield waitForLoad();
-  is(browser.contentWindow.location, DUMMY1, "Should have loaded the right URL");
-  is(browser.contentDocument.referrer, DUMMY2, "Should have the right referrer");
+
+  yield ContentTask.spawn(browser, [ DUMMY1, DUMMY2 ], function([dummy1, dummy2]) {
+    is(content.location, dummy1, "Should have loaded the right URL");
+    is(content.document.referrer, dummy2, "Should have the right referrer");
+  });
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that remote access to webnavigation.sessionHistory works.
 add_task(function* test_history() {
+  function checkHistoryIndex(browser, n) {
+    return ContentTask.spawn(browser, n, function(n) {
+      let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                            .getInterface(Ci.nsISHistory);
+      is(history.index, n, "Should be at the right place in history");
+    });
+  }
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
   yield waitForLoad();
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
   yield waitForLoad();
 
-  let history = browser.webNavigation.sessionHistory;
-  is(history.count, 2, "Should be two history items");
-  is(history.index, 1, "Should be at the right place in history");
-  let entry = history.getEntryAtIndex(0, false);
-  is(entry.URI.spec, DUMMY1, "Should have the right history entry");
-  entry = history.getEntryAtIndex(1, false);
-  is(entry.URI.spec, DUMMY2, "Should have the right history entry");
+  yield ContentTask.spawn(browser, [DUMMY1, DUMMY2], function([dummy1, dummy2]) {
+    let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsISHistory);
+    is(history.count, 2, "Should be two history items");
+    is(history.index, 1, "Should be at the right place in history");
+    let entry = history.getEntryAtIndex(0, false);
+    is(entry.URI.spec, dummy1, "Should have the right history entry");
+    entry = history.getEntryAtIndex(1, false);
+    is(entry.URI.spec, dummy2, "Should have the right history entry");
+  });
 
   let promise = waitForPageShow();
   browser.webNavigation.goBack();
   yield promise;
-  is(history.index, 0, "Should be at the right place in history");
+  yield checkHistoryIndex(browser, 0);
 
   promise = waitForPageShow();
   browser.webNavigation.goForward();
   yield promise;
-  is(history.index, 1, "Should be at the right place in history");
+  yield checkHistoryIndex(browser, 1);
 
   promise = waitForPageShow();
   browser.webNavigation.gotoIndex(0);
   yield promise;
-  is(history.index, 0, "Should be at the right place in history");
+  yield checkHistoryIndex(browser, 0);
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that load flags are passed through to the content process.
 add_task(function* test_flags() {
+  function checkHistory(browser, { count, index }) {
+    return ContentTask.spawn(browser, [ DUMMY2, count, index ],
+      function([ dummy2, count, index ]) {
+        let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                              .getInterface(Ci.nsISHistory);
+        is(history.count, count, "Should be one history item");
+        is(history.index, index, "Should be at the right place in history");
+        let entry = history.getEntryAtIndex(index, false);
+        is(entry.URI.spec, dummy2, "Should have the right history entry");
+      });
+  }
+
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
   yield waitForLoad();
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
                                 null, null, null);
   yield waitForLoad();
-
-  let history = browser.webNavigation.sessionHistory;
-  is(history.count, 1, "Should be one history item");
-  is(history.index, 0, "Should be at the right place in history");
-  let entry = history.getEntryAtIndex(0, false);
-  is(entry.URI.spec, DUMMY2, "Should have the right history entry");
+  yield checkHistory(browser, { count: 1, index: 0 });
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
                                 null, null, null);
   yield waitForLoad();
-
-  is(history.count, 1, "Should still be one history item");
-  is(history.index, 0, "Should be at the right place in history");
-  entry = history.getEntryAtIndex(0, false);
-  is(entry.URI.spec, DUMMY2, "Should have the right history entry");
+  yield checkHistory(browser, { count: 1, index: 0 });
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that attempts to use unsupported arguments throw an exception.
 add_task(function* test_badarguments() {
   if (!gMultiProcessBrowser)
     return;