Bug 1443958 - Synthesizing a click() on input type=date should not show the date picker UI. r=mconley, a=jcristau
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 30 Mar 2018 02:51:17 +0300
changeset 463066 456c098f27d4c2ca80b25be633e31498fa6f3c44
parent 463065 eae4410ea11d83feed90ca9d3b6bd5a9c67c17a7
child 463067 968f78c16b2261b8a5bf11dee8099a3b94887046
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, jcristau
bugs1443958
milestone60.0
Bug 1443958 - Synthesizing a click() on input type=date should not show the date picker UI. r=mconley, a=jcristau
dom/html/test/forms/test_input_date_key_events.html
toolkit/content/widgets/datetimebox.xml
--- a/dom/html/test/forms/test_input_date_key_events.html
+++ b/dom/html/test/forms/test_input_date_key_events.html
@@ -215,14 +215,23 @@ function test() {
     elem.focus();
     elem.value = initialVal;
     sendKeys(keys);
     elem.blur();
     is(elem.value, expectedVal,
        "Test with " + keys + ", result should be " + expectedVal);
     elem.value = "";
   }
+
+  function chromeListener(e) {
+    ok(false, "Picker should not be opened when dispatching untrusted click.");
+  }
+  SpecialPowers.addChromeEventListener("MozOpenDateTimePicker",
+    chromeListener);
+  input.click();
+  SpecialPowers.removeChromeEventListener("MozOpenDateTimePicker",
+    chromeListener);
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/content/widgets/datetimebox.xml
+++ b/toolkit/content/widgets/datetimebox.xml
@@ -1239,27 +1239,28 @@
         this.mStep = this.mInputElement.step;
         this.mIsPickerOpen = false;
 
         this.mResetButton =
           document.getAnonymousElementByAttribute(this, "anonid", "reset-button");
         this.mResetButton.style.visibility = "hidden";
 
         this.EVENTS.forEach((eventName) => {
-          this.addEventListener(eventName, this, { mozSystemGroup: true });
+          this.addEventListener(eventName, this, { mozSystemGroup: true }, false);
         });
         // Handle keypress separately since we need to catch it on capturing.
         this.addEventListener("keypress", this, {
           capture: true,
           mozSystemGroup: true
-        });
+        }, false);
         // This is to open the picker when input element is clicked (this
         // includes padding area).
         this.mInputElement.addEventListener("click", this,
-                                            { mozSystemGroup: true });
+                                            { mozSystemGroup: true },
+                                            false);
       ]]>
       </constructor>
 
       <destructor>
       <![CDATA[
         this.EVENTS.forEach((eventName) => {
           this.removeEventListener(eventName, this, { mozSystemGroup: true });
         });