Bug 1100291 - Fix a few tests to wait until a newly opened tab is loaded before using for further testing r=Gijs
authorTim Taubert <ttaubert@mozilla.com>
Tue, 17 Mar 2015 18:49:54 +0100
changeset 265861 2894f27c8ca7bf2259f1b6c0b961b01f10376c40
parent 265860 cccba602c83ae61d905264256aff0256f45b16e4
child 265862 97076df948c275036021a45da7347df3bae7acf5
child 266012 01482cdccd72b4f36f10ff3706a92c4c77c48253
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1100291
milestone39.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 1100291 - Fix a few tests to wait until a newly opened tab is loaded before using for further testing r=Gijs
browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js
browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
browser/base/content/test/general/browser_urlbar_search_healthreport.js
--- a/browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js
+++ b/browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js
@@ -1,33 +1,35 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-add_task(function(){
+add_task(function* () {
   // Test that changing the URL in a pinned tab works correctly
 
   let TEST_LINK_INITIAL = "about:";
   let TEST_LINK_CHANGED = "about:support";
 
   let appTab = gBrowser.addTab(TEST_LINK_INITIAL);
+  let browser = appTab.linkedBrowser;
+  yield BrowserTestUtils.browserLoaded(browser);
+
   gBrowser.pinTab(appTab);
   is(appTab.pinned, true, "Tab was successfully pinned");
 
   let initialTabsNo = gBrowser.tabs.length;
 
   let goButton = document.getElementById("urlbar-go-button");
   gBrowser.selectedTab = appTab;
   gURLBar.focus();
   gURLBar.value = TEST_LINK_CHANGED;
 
-  let promisePageload = promiseTabLoadEvent(appTab);
   goButton.click();
-  yield promisePageload;
+  yield BrowserTestUtils.browserLoaded(browser);
 
   is(appTab.linkedBrowser.currentURI.spec, TEST_LINK_CHANGED,
      "New page loaded in the app tab");
   is(gBrowser.tabs.length, initialTabsNo, "No additional tabs were opened");
 });
 
 registerCleanupFunction(function () {
   gBrowser.removeTab(gBrowser.selectedTab);
--- a/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
@@ -55,23 +55,25 @@ function* runURLBarSearchTest(valueToOpe
 
   yield Promise.all([
     docLoadPromise,
     promiseNotificationForTab(aWindow.gBrowser, "keyword-uri-fixup", expectNotification)
   ]);
 }
 
 add_task(function* test_navigate_full_domain() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield* runURLBarSearchTest("www.mozilla.org", false, false);
   gBrowser.removeTab(tab);
 });
 
 add_task(function* test_navigate_numbers() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield* runURLBarSearchTest("1234", true, false);
   gBrowser.removeTab(tab);
 });
 
 function get_test_function_for_localhost_with_hostname(hostName, isPrivate) {
   return function* test_navigate_single_host() {
     const pref = "browser.fixup.domainwhitelist.localhost";
     let win;
@@ -79,17 +81,18 @@ function get_test_function_for_localhost
       win = yield promiseOpenAndLoadWindow({private: true}, true);
       let deferredOpenFocus = Promise.defer();
       waitForFocus(deferredOpenFocus.resolve, win);
       yield deferredOpenFocus.promise;
     } else {
       win = window;
     }
     let browser = win.gBrowser;
-    let tab = browser.selectedTab = browser.addTab();
+    let tab = browser.selectedTab = browser.addTab("about:blank");
+    yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
     Services.prefs.setBoolPref(pref, false);
     yield* runURLBarSearchTest(hostName, true, true, win);
 
     let notificationBox = browser.getNotificationBox(tab.linkedBrowser);
     let notification = notificationBox.getNotificationWithValue("keyword-uri-fixup");
     let docLoadPromise = waitForDocLoadAndStopIt("http://" + hostName + "/", tab.linkedBrowser);
     notification.querySelector(".notification-button-default").click();
@@ -97,17 +100,18 @@ function get_test_function_for_localhost
     // check pref value
     let prefValue = Services.prefs.getBoolPref(pref);
     is(prefValue, !isPrivate, "Pref should have the correct state.");
 
     yield docLoadPromise;
     browser.removeTab(tab);
 
     // Now try again with the pref set.
-    tab = browser.selectedTab = browser.addTab();
+    tab = browser.selectedTab = browser.addTab("about:blank");
+    yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
     // In a private window, the notification should appear again.
     yield* runURLBarSearchTest(hostName, isPrivate, isPrivate, win);
     browser.removeTab(tab);
     if (isPrivate) {
       info("Waiting for private window to close");
       yield promiseWindowClosed(win);
       let deferredFocus = Promise.defer();
       info("Waiting for focus");
@@ -117,12 +121,13 @@ function get_test_function_for_localhost
   }
 }
 
 add_task(get_test_function_for_localhost_with_hostname("localhost"));
 add_task(get_test_function_for_localhost_with_hostname("localhost."));
 add_task(get_test_function_for_localhost_with_hostname("localhost", true));
 
 add_task(function* test_navigate_invalid_url() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield* runURLBarSearchTest("mozilla is awesome", true, false);
   gBrowser.removeTab(tab);
 });
--- a/browser/base/content/test/general/browser_urlbar_search_healthreport.js
+++ b/browser/base/content/test/general/browser_urlbar_search_healthreport.js
@@ -34,17 +34,18 @@ add_task(function* test_healthreport_sea
 
   if (data.days.hasDay(now)) {
     let day = data.days.getDay(now);
     if (day.has(field)) {
       oldCount = day.get(field);
     }
   }
 
-  let tab = gBrowser.addTab();
+  let tab = gBrowser.addTab("about:blank");
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   gBrowser.selectedTab = tab;
 
   let searchStr = "firefox health report";
   let expectedURL = Services.search.currentEngine.
                     getSubmission(searchStr, "", "keyword").uri.spec;
 
   // Expect the search URL to load but stop it as soon as it starts.
   let docLoadPromise = waitForDocLoadAndStopIt(expectedURL);