Bug 1624936: Fire state change event when required state changes. r=eeejay
authorMorgan Reschenberg <mreschenberg@mozilla.com>
Tue, 28 Apr 2020 18:19:17 +0000
changeset 526550 d117eac2aafe1493ae3d3d5b494368d8764a7cc9
parent 526549 6cdc2132e4de12ea6588f668b58edae5d6450342
child 526551 160413fb8acbb4101934c8e92920b1141f8a4f36
push id37358
push useropoprus@mozilla.com
push dateWed, 29 Apr 2020 03:05:14 +0000
treeherdermozilla-central@6bb8423186c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs1624936
milestone77.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 1624936: Fire state change event when required state changes. r=eeejay Differential Revision: https://phabricator.services.mozilla.com/D71413
accessible/generic/DocAccessible.cpp
accessible/tests/mochitest/events/test_statechange.html
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1108,16 +1108,22 @@ void DocAccessible::ContentStateChanged(
   }
 
   if (aStateMask.HasState(NS_EVENT_STATE_INVALID)) {
     RefPtr<AccEvent> event =
         new AccStateChangeEvent(accessible, states::INVALID, true);
     FireDelayedEvent(event);
   }
 
+  if (aStateMask.HasState(NS_EVENT_STATE_REQUIRED)) {
+    RefPtr<AccEvent> event =
+        new AccStateChangeEvent(accessible, states::REQUIRED, true);
+    FireDelayedEvent(event);
+  }
+
   if (aStateMask.HasState(NS_EVENT_STATE_VISITED)) {
     RefPtr<AccEvent> event =
         new AccStateChangeEvent(accessible, states::TRAVERSED, true);
     FireDelayedEvent(event);
   }
 }
 
 void DocAccessible::CharacterDataWillChange(nsIContent* aContent,
--- a/accessible/tests/mochitest/events/test_statechange.html
+++ b/accessible/tests/mochitest/events/test_statechange.html
@@ -49,16 +49,22 @@
     }
 
     async function changeCheckInput(aID, aIsChecked) {
       let p = waitForEvent(...stateChange(STATE_CHECKED, false, aIsChecked, aID));
       getNode(aID).checked = aIsChecked;
       await p;
     }
 
+    async function changeRequiredState(aID, aIsRequired) {
+      let p = waitForEvent(...stateChange(STATE_REQUIRED, false, aIsRequired, aID));
+      getNode(aID).required = aIsRequired;
+      await p;
+    }
+
     async function stateChangeOnFileInput(aID, aAttr, aValue,
                                     aState, aIsExtraState, aIsEnabled) {
       let fileControlNode = getNode(aID);
       let fileControl = getAccessible(fileControlNode);
       let browseButton = fileControl.firstChild;
       let p = waitForEvents([
         stateChange(aState, aIsExtraState, aIsEnabled, fileControl),
         stateChange(aState, aIsExtraState, aIsEnabled, browseButton)])
@@ -150,16 +156,19 @@
       await invalidInput("email");
 
       // checked state change
       await changeCheckInput("checkbox", true);
       await changeCheckInput("checkbox", false);
       await changeCheckInput("radio", true);
       await changeCheckInput("radio", false);
 
+      // required state change
+      await changeRequiredState("checkbox", true);
+
       // file input inherited state changes
       await stateChangeOnFileInput("file", "aria-busy", "true",
                                    STATE_BUSY, false, true);
       await stateChangeOnFileInput("file", "aria-required", "true",
                                    STATE_REQUIRED, false, true);
       await stateChangeOnFileInput("file", "aria-invalid", "true",
                                    STATE_INVALID, false, true);