Bug 1099154, e10s, fix and reenable browser_backButtonFitts.js, r=gijs
authorNeil Deakin <neil@mozilla.com>
Mon, 11 May 2015 08:02:49 -0400
changeset 243359 41ca098906eb231f1d99bc60c82b8b7dddda43a9
parent 243358 1c15a3d5906b7fa05000ff4e5698513b8699383c
child 243360 10f5abd1c9126f2f717bd21f2e93199f859a3dd2
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs
bugs1099154
milestone40.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 1099154, e10s, fix and reenable browser_backButtonFitts.js, r=gijs
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_backButtonFitts.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -132,17 +132,17 @@ skip-if = e10s # Bug 1093153 - no about:
 [browser_autocomplete_a11y_label.js]
 skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir (works on its own)
 [browser_autocomplete_enter_race.js]
 [browser_autocomplete_no_title.js]
 [browser_autocomplete_autoselect.js]
 [browser_autocomplete_oldschool_wrap.js]
 [browser_autocomplete_tag_star_visibility.js]
 [browser_backButtonFitts.js]
-skip-if = os != "win" || e10s # The Fitts Law back button is only supported on Windows (bug 571454) / e10s - Bug 1099154: test touches content (attempts to add an event listener directly to the contentWindow)
+skip-if = os != "win" # The Fitts Law back button is only supported on Windows (bug 571454)
 [browser_beforeunload_duplicate_dialogs.js]
 skip-if = e10s # bug 967873 means permitUnload doesn't work in e10s mode
 [browser_blob-channelname.js]
 [browser_bookmark_titles.js]
 skip-if = buildapp == 'mulet' || toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341)
 [browser_bug304198.js]
 [browser_bug321000.js]
 skip-if = true # browser_bug321000.js is disabled because newline handling is shaky (bug 592528)
--- a/browser/base/content/test/general/browser_backButtonFitts.js
+++ b/browser/base/content/test/general/browser_backButtonFitts.js
@@ -1,30 +1,42 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-function test () {
-  waitForExplicitFinish();
-  var firstLocation = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
-  gBrowser.selectedTab = gBrowser.addTab(firstLocation);
-  gBrowser.selectedBrowser.addEventListener("pageshow", function onPageShow1() {
-    gBrowser.selectedBrowser.removeEventListener("pageshow", onPageShow1);
-    gBrowser.selectedBrowser.contentWindow.history.pushState("page2", "page2", "page2");
-    window.maximize();
+add_task(function* () {
+  let firstLocation = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser, firstLocation);
+
+  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
+    // Push the state before maximizing the window and clicking below.
+    content.history.pushState("page2", "page2", "page2");
 
-    // Find where the nav-bar is vertically.
-    var navBar = document.getElementById("nav-bar");
-    var boundingRect = navBar.getBoundingClientRect();
-    var yPixel = boundingRect.top + Math.floor(boundingRect.height / 2);
-    var xPixel = 0; // Use the first pixel of the screen since it is maximized.
+    // While in the child process, add a listener for the popstate event here. This
+    // event will fire when the mouse click happens.
+    content.addEventListener("popstate", function onPopState() {
+      content.removeEventListener("popstate", onPopState, false);
+      sendAsyncMessage("Test:PopStateOccurred", { location: content.document.location.href });
+    }, false);
+  });
+
+  window.maximize();
 
-    gBrowser.selectedBrowser.contentWindow.addEventListener("popstate", function onPopState() {
-      gBrowser.selectedBrowser.contentWindow.removeEventListener("popstate", onPopState);
-      is(gBrowser.selectedBrowser.contentDocument.location.href, firstLocation,
-         "Clicking the first pixel should have navigated back.");
-      window.restore();
-      gBrowser.removeCurrentTab();
-      finish();
+  // Find where the nav-bar is vertically.
+  var navBar = document.getElementById("nav-bar");
+  var boundingRect = navBar.getBoundingClientRect();
+  var yPixel = boundingRect.top + Math.floor(boundingRect.height / 2);
+  var xPixel = 0; // Use the first pixel of the screen since it is maximized.
+
+  let resultLocation = yield new Promise(resolve => {
+    messageManager.addMessageListener("Test:PopStateOccurred", function statePopped(message) {
+      messageManager.removeMessageListener("Test:PopStateOccurred", statePopped);
+      resolve(message.data.location);
     });
+
     EventUtils.synthesizeMouseAtPoint(xPixel, yPixel, {}, window);
   });
-}
+
+  is(resultLocation, firstLocation, "Clicking the first pixel should have navigated back.");
+  window.restore();
+
+  gBrowser.removeCurrentTab();
+});