From 197e47c6a7c9063fac665a28a16d7627ed3214f3 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Tue, 14 Jun 2016 08:11:09 -0400 Subject: [PATCH] Bug 1279771 - Treat change events triggered by changing + + + + + +
+  
+
+ + diff --git a/toolkit/modules/SelectContentHelper.jsm b/toolkit/modules/SelectContentHelper.jsm index 1df3dffba09a..837afd17b9ab 100644 --- a/toolkit/modules/SelectContentHelper.jsm +++ b/toolkit/modules/SelectContentHelper.jsm @@ -114,29 +114,36 @@ this.SelectContentHelper.prototype = { case "Forms:DismissedDropDown": if (this.initialSelection != this.element.item(this.element.selectedIndex)) { let win = this.element.ownerDocument.defaultView; - 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, + let dwu = win.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + dwu.startHandlingUserInput(); + try { + let inputEvent = new win.UIEvent("input", { bubbles: true, - cancelable: true, }); - this.element.dispatchEvent(mouseEvent); + 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, + }); + this.element.dispatchEvent(mouseEvent); + } + } finally { + dwu.stopHandlingUserInput(); } }