Bug 1609589: Fire a value change event when the text of a spin button changes. r=MarcoZ
authorJames Teh <jteh@mozilla.com>
Thu, 16 Jan 2020 04:57:24 +0000
changeset 510434 198f7c0bb5bba88bcec19fffa3bfe38b161cf818
parent 510433 28c632950e5e3b7cf6998569a8b339a5775bead5
child 510435 ce4e1638e4721dd20ddd587b082bd5eca8b0503a
push id37021
push userrmaries@mozilla.com
push dateThu, 16 Jan 2020 09:46:51 +0000
treeherdermozilla-central@7541d616ff87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ
bugs1609589, 981248
milestone74.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 1609589: Fire a value change event when the text of a spin button changes. r=MarcoZ After bug 981248, <input type="number"> no longer has an anonymous text input. Instead, the <input type="number"> itself manages the text. Previously, the a11y code which fired value change events for text changes only did this for combo boxes and role ENTRY. This meant a value change event was no longer fired for <input type="number">. This condition has now been extended to include role SPINBUTTON. This fixes reporting of <input type="number"> changes for JAWS. Differential Revision: https://phabricator.services.mozilla.com/D60101
accessible/generic/DocAccessible-inl.h
accessible/tests/mochitest/events/test_valuechange.html
--- a/accessible/generic/DocAccessible-inl.h
+++ b/accessible/generic/DocAccessible-inl.h
@@ -107,18 +107,20 @@ inline void DocAccessible::NotifyOfLoad(
   if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
     RefPtr<AccEvent> stateEvent =
         new AccStateChangeEvent(this, states::BUSY, false);
     FireDelayedEvent(stateEvent);
   }
 }
 
 inline void DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible) {
-  if (aAccessible->IsCombobox() || aAccessible->Role() == roles::ENTRY)
+  if (aAccessible->IsCombobox() || aAccessible->Role() == roles::ENTRY ||
+      aAccessible->Role() == roles::SPINBUTTON) {
     FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE, aAccessible);
+  }
 }
 
 inline Accessible* DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(
     nsINode* aNode) const {
   Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
   return acc ? acc : GetContainerAccessible(aNode);
 }
 
--- a/accessible/tests/mochitest/events/test_valuechange.html
+++ b/accessible/tests/mochitest/events/test_valuechange.html
@@ -166,16 +166,18 @@
       gQueue.push(new changeSelectValue("select", "3", "3rd"));
 
       let iframeSelect = getAccessible("selectIframe").firstChild.firstChild;
       gQueue.push(new changeSelectValue(iframeSelect, "VK_DOWN", "2"));
 
       let shadowSelect = getAccessible("selectShadow").firstChild;
       gQueue.push(new changeSelectValue(shadowSelect, "VK_DOWN", "2"));
 
+      gQueue.push(new changeValue("number", "2"));
+
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
 
@@ -264,10 +266,12 @@
     let option = document.createElement("option");
     option.textContent = "1";
     select.appendChild(option);
     option = document.createElement("option");
     option.textContent = "2";
     select.appendChild(option);
     shadow.appendChild(select);
   </script>
+
+  <input type="number" id="number" value="1">
 </body>
 </html>