Bug 1100291 - Fix docshell/test/browser/browser_uriFixupIntegration.js to properly work with an async version of getShortcutOrURIAndPostData() and make it e10s compatible r=Gijs
authorTim Taubert <ttaubert@mozilla.com>
Fri, 06 Mar 2015 16:37:26 +0100
changeset 264395 4756d973a34c53bf51b42fee3aebcd672c3dcf2b
parent 264394 5727e5db4bb186d84b157609fdee9d12b3fe251f
child 264396 51ca14f617a6e5fb575818e2e7fe066909799ab8
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [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 docshell/test/browser/browser_uriFixupIntegration.js to properly work with an async version of getShortcutOrURIAndPostData() and make it e10s compatible r=Gijs
docshell/test/browser/browser.ini
docshell/test/browser/browser_uriFixupIntegration.js
--- a/docshell/test/browser/browser.ini
+++ b/docshell/test/browser/browser.ini
@@ -89,17 +89,16 @@ skip-if = e10s # Bug ?????? - PlacesUtil
 skip-if = e10s # Bug 916974 - browser.sessionHistory is null
 [browser_bug673467.js]
 skip-if = e10s # Bug ?????? - test touches content (adds event listener to content document's iframe)
 [browser_bug852909.js]
 skip-if = e10s # Bug ?????? - event handler checks event.target is the content document and test e10s-utils doesn't do that.
 [browser_bug92473.js]
 skip-if = e10s # Bug ?????? - event handler checks event.target is the content document and test e10s-utils doesn't do that.
 [browser_uriFixupIntegration.js]
-skip-if = e10s
 [browser_loadDisallowInherit.js]
 skip-if = e10s
 [browser_loadURI.js]
 skip-if = e10s # Bug ?????? - event handler checks event.target is the content document and test e10s-utils doesn't do that.
 [browser_onbeforeunload_navigation.js]
 skip-if = e10s
 [browser_search_notification.js]
 [browser_timelineMarkers-01.js]
--- a/docshell/test/browser/browser_uriFixupIntegration.js
+++ b/docshell/test/browser/browser_uriFixupIntegration.js
@@ -1,80 +1,51 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
+"use strict";
 
 const kSearchEngineID = "browser_urifixup_search_engine";
 const kSearchEngineURL = "http://example.com/?search={searchTerms}";
-Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
-                                     kSearchEngineURL);
+
+add_task(function* setup() {
+  // Add a new fake search engine.
+  Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
+                                       kSearchEngineURL);
 
-let oldDefaultEngine = Services.search.defaultEngine;
-Services.search.defaultEngine = Services.search.getEngineByName(kSearchEngineID);
+  let oldDefaultEngine = Services.search.defaultEngine;
+  Services.search.defaultEngine = Services.search.getEngineByName(kSearchEngineID);
 
-let tab;
-let searchParams;
+  // Remove the fake engine when done.
+  registerCleanupFunction(() => {
+    if (oldDefaultEngine) {
+      Services.search.defaultEngine = oldDefaultEngine;
+    }
 
-function checkURL() {
-  let escapedParams = encodeURIComponent(searchParams).replace("%20", "+");
-  let expectedURL = kSearchEngineURL.replace("{searchTerms}", escapedParams);
-  is(tab.linkedBrowser.currentURI.spec, expectedURL,
-     "New tab should have loaded with expected url.");
-}
+    let engine = Services.search.getEngineByName(kSearchEngineID);
+    if (engine) {
+      Services.search.removeEngine(engine);
+    }
+  });
+});
 
-function addPageShowListener(aFunc) {
-  gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
-    gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
-    aFunc();
-  });
-}
+add_task(function* test() {
+  for (let searchParams of ["foo bar", "brokenprotocol:somethingelse"]) {
+    // Add a new blank tab.
+    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
-function locationBarEnter(aCallback) {
-  executeSoon(function() {
+    // Enter search terms and start a search.
+    gURLBar.value = searchParams;
     gURLBar.focus();
     EventUtils.synthesizeKey("VK_RETURN", {});
-    addPageShowListener(aCallback);
-  });
-}
-
-let urlbarInput = [
-  "foo bar",
-  "brokenprotocol:somethingelse"
-];
-function test() {
-  waitForExplicitFinish();
-
-  nextTest();
-}
-
-function nextTest() {
-  searchParams = urlbarInput.pop();
-  tab = gBrowser.selectedTab = gBrowser.addTab();
+    yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
-  gURLBar.value = searchParams;
-  locationBarEnter(function() {
-    checkURL();
-    gBrowser.removeTab(tab);
-    tab = null;
-    if (urlbarInput.length) {
-      nextTest();
-    } else {
-      finish();
-    }
-  });
-}
+    // Check that we arrived at the correct URL.
+    let escapedParams = encodeURIComponent(searchParams).replace("%20", "+");
+    let expectedURL = kSearchEngineURL.replace("{searchTerms}", escapedParams);
+    is(gBrowser.selectedBrowser.currentURI.spec, expectedURL,
+       "New tab should have loaded with expected url.");
 
-registerCleanupFunction(function () {
-  if (tab) {
-    gBrowser.removeTab(tab);
-  }
-
-  if (oldDefaultEngine) {
-    Services.search.defaultEngine = oldDefaultEngine;
-  }
-  let engine = Services.search.getEngineByName(kSearchEngineID);
-  if (engine) {
-    Services.search.removeEngine(engine);
+    // Cleanup.
+    gBrowser.removeCurrentTab();
   }
 });
-