Bug 1345214 - Wait for the right pages to load. r=krizsa, a=test-only
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 13 Mar 2017 16:19:50 -0700
changeset 379066 dee74fdbfbeedcd56517b90366c7b48e5abe6697
parent 379065 762fb663380ac609c72d2c55febeb9b5573bcf00
child 379067 8eefcde96334ddb87f76ce97cb21d18b7096f017
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskrizsa, test-only
bugs1345214
milestone53.0
Bug 1345214 - Wait for the right pages to load. r=krizsa, a=test-only Because we weren't waiting for the first, "about:blank" page to load, the first `waitForLoad` could trigger for about:blank. Rather than add an additional `waitForLoad` it's easier (and probably more future-proof) to just wait for the right page to load. MozReview-Commit-ID: DZsMnlgRTa
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,15 +1,15 @@
 /* eslint-env mozilla/frame-script */
 
 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 BrowserTestUtils.browserLoaded(browser);
+function waitForLoad(uri) {
+  return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
 }
 
 function waitForPageShow(browser = gBrowser.selectedBrowser) {
   return BrowserTestUtils.waitForContentEvent(browser, "pageshow", true);
 }
 
 function makeURI(url) {
   return Cc["@mozilla.org/network/io-service;1"].
@@ -21,20 +21,20 @@ function makeURI(url) {
 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();
+  yield waitForLoad(DUMMY1);
 
   yield ContentTask.spawn(browser, [ DUMMY1, DUMMY2 ], function([dummy1, dummy2]) {
-    is(content.location, dummy1, "Should have loaded the right URL");
+    is(content.location.href, 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() {
@@ -46,22 +46,22 @@ add_task(function* test_history() {
     });
   }
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
-  yield waitForLoad();
+  yield waitForLoad(DUMMY1);
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
-  yield waitForLoad();
+  yield waitForLoad(DUMMY2);
 
   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");
@@ -102,28 +102,28 @@ add_task(function* test_flags() {
   }
 
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
                                 null, null, null);
-  yield waitForLoad();
+  yield waitForLoad(DUMMY1);
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
                                 null, null, null);
-  yield waitForLoad();
+  yield waitForLoad(DUMMY2);
   yield checkHistory(browser, { count: 1, index: 0 });
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
                                 null, null, null);
-  yield waitForLoad();
+  yield waitForLoad(DUMMY1);
   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)