Bug 1270117 - Modify browser_focus_steal_from_chrome_during_mousedown to run on e10s, r=enndeakin
authorMichael Layzell <michael@thelayzells.com>
Tue, 03 May 2016 11:59:14 -0400
changeset 296425 55145c24a7d341a9c524a9094440f54bffb3b3ad
parent 296424 1a43ff2baca5aa9ac94209b0fb6ebe7e5b1f0d6b
child 296426 33bc6f2614494889149986aee3460e0d2b5f600e
push id76326
push usermichael@thelayzells.com
push dateFri, 06 May 2016 17:53:51 +0000
treeherdermozilla-inbound@ef13bb5a11d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1270117
milestone49.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 1270117 - Modify browser_focus_steal_from_chrome_during_mousedown to run on e10s, r=enndeakin
dom/tests/browser/browser.ini
dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
--- a/dom/tests/browser/browser.ini
+++ b/dom/tests/browser/browser.ini
@@ -25,17 +25,16 @@ skip-if = e10s
 skip-if = e10s
 [browser_autofocus_background.js]
 skip-if= buildapp == 'mulet'
 [browser_autofocus_preference.js]
 [browser_bug1238427.js]
 [browser_bug396843.js]
 [browser_focus_steal_from_chrome.js]
 [browser_focus_steal_from_chrome_during_mousedown.js]
-skip-if = e10s
 [browser_frame_elements.js]
 [browser_localStorage_privatestorageevent.js]
 [browser_test_new_window_from_content.js]
 skip-if = (toolkit == 'android' || buildapp == 'b2g' || buildapp == 'mulet') || (os == "linux" && debug) # see bug 1261495 for Linux debug time outs
 support-files =
   test_new_window_from_content_child.html
 [browser_webapps_permissions.js]
 # TODO: Re-enable permissions tests on Mac, bug 795334
--- a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
@@ -1,59 +1,45 @@
-function test() {
-  waitForExplicitFinish();
-
+add_task(function* test() {
   const kTestURI =
     "data:text/html," +
     "<script type=\"text/javascript\">" +
     "  function onMouseDown(aEvent) {" +
     "    document.getElementById('willBeFocused').focus();" +
     "    aEvent.preventDefault();" +
     "  }" +
     "</script>" +
     "<body id=\"body\">" +
-    "<button id=\"eventTarget\" onmousedown=\"onMouseDown(event);\">click here</button>" +
+    "<button onmousedown=\"onMouseDown(event);\" style=\"width: 100px; height: 100px;\">click here</button>" +
     "<input id=\"willBeFocused\"></body>";
 
-  let tab = gBrowser.addTab();
-  gBrowser.selectedTab = tab;
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, kTestURI);
+
+  let fm = Components.classes["@mozilla.org/focus-manager;1"].
+        getService(Components.interfaces.nsIFocusManager);
+
+  for (var button = 0; button < 3; button++) {
+    // Set focus to a chrome element before synthesizing a mouse down event.
+    document.getElementById("urlbar").focus();
+
+    is(fm.focusedElement, document.getElementById("urlbar").inputField,
+       "Failed to move focus to search bar: button=" + button);
 
-  // Set the focus to the contents.
-  tab.linkedBrowser.focus();
-  // Load on the tab
-  tab.linkedBrowser.addEventListener("load", onLoadTab, true);
-  tab.linkedBrowser.loadURI(kTestURI);
+    // Synthesize mouse down event on browser object over the button, such that
+    // the event propagates through both processes.
+    EventUtils.synthesizeMouse(tab.linkedBrowser, 20, 20, { "button": button }, null);
+
+    isnot(fm.focusedElement, document.getElementById("urlbar").inputField,
+       "Failed to move focus away from search bar: button=" + button);
 
-  function onLoadTab() {
-    tab.linkedBrowser.removeEventListener("load", onLoadTab, true);
-    setTimeout(doTest, 0);
+    yield ContentTask.spawn(tab.linkedBrowser, button, function (button) {
+      let fm = Components.classes["@mozilla.org/focus-manager;1"].
+            getService(Components.interfaces.nsIFocusManager);
+
+      Assert.equal(content.document.activeElement.id, "willBeFocused",
+                   "The input element isn't active element: button=" + button);
+      Assert.equal(fm.focusedElement, content.document.activeElement,
+                   "The active element isn't focused element in App level: button=" + button);
+    });
   }
 
-  function doTest() {
-    let fm = Components.classes["@mozilla.org/focus-manager;1"].
-                        getService(Components.interfaces.nsIFocusManager);
-    let eventTarget =
-      tab.linkedBrowser.contentDocument.getElementById("eventTarget");
-
-    for (var button = 0; button < 3; button++) {
-      // Set focus to a chrome element before synthesizing a mouse down event.
-      document.getElementById("urlbar").focus();
-
-      is(fm.focusedElement, document.getElementById("urlbar").inputField,
-         "Failed to move focus to search bar: button=" +
-         button);
-
-      EventUtils.synthesizeMouse(eventTarget, 10, 10, { "button": button },
-                                 tab.linkedBrowser.contentWindow);
-
-      let e = tab.linkedBrowser.contentDocument.activeElement;
-      is(e.id, "willBeFocused",
-         "The input element isn't active element: button=" + button);
-
-      is(fm.focusedElement, e,
-         "The active element isn't focused element in App level: button=" +
-         button);
-    }
-
-    gBrowser.removeTab(tab);
-    finish();
-  }
-}
+  gBrowser.removeTab(tab);
+});