Bug 1291078 - Re-arrange events fired on <option> elements for e10s to match non-e10s. r=Enn a=lizzard
authorMike Conley <mconley@mozilla.com>
Fri, 05 Aug 2016 17:15:43 -0400
changeset 332651 fb956712e50f
parent 332650 cff9e0a1ca42
child 332652 93f9fde505f4
push id9888
push userkwierso@gmail.com
push dateWed, 10 Aug 2016 17:37:29 +0000
treeherdermozilla-aurora@f5a9d33557dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn, lizzard
bugs1291078
milestone50.0a2
Bug 1291078 - Re-arrange events fired on <option> elements for e10s to match non-e10s. r=Enn a=lizzard MozReview-Commit-ID: HvekgOrNoNA
browser/base/content/test/general/browser_selectpopup.js
toolkit/modules/SelectContentHelper.jsm
--- a/browser/base/content/test/general/browser_selectpopup.js
+++ b/browser/base/content/test/general/browser_selectpopup.js
@@ -302,32 +302,32 @@ add_task(function* test_event_order() {
     yield openSelectPopup(selectPopup, true, "#one");
 
     let eventsPromise = ContentTask.spawn(browser, null, function*() {
       // According to https://html.spec.whatwg.org/#the-select-element,
       // we want to fire input, change, and then click events on the
       // <select> (in that order) when it has changed.
       let expected = [
         {
+          type: "mousedown",
+          cancelable: true,
+        },
+        {
+          type: "mouseup",
+          cancelable: true,
+        },
+        {
           type: "input",
           cancelable: false,
         },
         {
           type: "change",
           cancelable: false,
         },
         {
-          type: "mousedown",
-          cancelable: true,
-        },
-        {
-          type: "mouseup",
-          cancelable: true,
-        },
-        {
           type: "click",
           cancelable: true,
         },
       ];
 
       return new Promise((resolve) => {
         function onEvent(event) {
           select.removeEventListener(event.type, onEvent);
--- a/toolkit/modules/SelectContentHelper.jsm
+++ b/toolkit/modules/SelectContentHelper.jsm
@@ -113,43 +113,46 @@ this.SelectContentHelper.prototype = {
       case "Forms:SelectDropDownItem":
         this.element.selectedIndex = message.data.value;
         break;
 
       case "Forms:DismissedDropDown":
         let selectedOption = this.element.item(this.element.selectedIndex);
         if (this.initialSelection != selectedOption) {
           let win = this.element.ownerDocument.defaultView;
+          // For ordering of events, we're using non-e10s as our guide here,
+          // since the spec isn't exactly clear. In non-e10s, we fire:
+          // mousedown, mouseup, input, change, click.
+          const MOUSE_EVENTS = ["mousedown", "mouseup"];
+          for (let eventName of MOUSE_EVENTS) {
+            let mouseEvent = new win.MouseEvent(eventName, {
+              view: win,
+              bubbles: true,
+              cancelable: true,
+            });
+            selectedOption.dispatchEvent(mouseEvent);
+          }
+          DOMUtils.removeContentState(this.element, kStateActive);
+
           let inputEvent = new win.UIEvent("input", {
             bubbles: true,
           });
           this.element.dispatchEvent(inputEvent);
 
           let changeEvent = new win.Event("change", {
             bubbles: true,
           });
           this.element.dispatchEvent(changeEvent);
 
-          // Going for mostly-Blink parity here, which (at least on Windows)
-          // fires a mouseup and click event after each selection -
-          // even by keyboard. We're firing a mousedown too, since that
-          // seems to make more sense. Unfortunately, the spec on form
-          // control behaviours for these events is really not clear.
-          const MOUSE_EVENTS = ["mousedown", "mouseup", "click"];
-          for (let eventName of MOUSE_EVENTS) {
-            let mouseEvent = new win.MouseEvent(eventName, {
-              view: win,
-              bubbles: true,
-              cancelable: true,
-            });
-            selectedOption.dispatchEvent(mouseEvent);
-            if (eventName == "mouseup") {
-              DOMUtils.removeContentState(this.element, kStateActive);
-            }
-          }
+          let mouseEvent = new win.MouseEvent("click", {
+            view: win,
+            bubbles: true,
+            cancelable: true,
+          });
+          selectedOption.dispatchEvent(mouseEvent);
         }
 
         this.uninit();
         break;
 
       case "Forms:MouseOver":
         DOMUtils.setContentState(this.element, kStateHover);
         break;