Commit 432c5070 authored by James Teh's avatar James Teh
Browse files

Bug 1833079: When notified about a dom::ElementState::INVALID change, let...

Bug 1833079: When notified about a dom::ElementState::INVALID change, let AccStateChangeEvent calculate whether the state is enabled. r=morgan a=pascalc

Previously, we passed true for aIsEnabled, indicating that the state was only ever enabled, never disabled.
We could get the actual enabled value here using dom::ElementState::HasState(), but that wouldn't take aria-invalid into account if present.
Instead, we let AccStateChangeEvent calculate it by calling Accessible::State().

Differential Revision: https://phabricator.services.mozilla.com/D178039
parent 05d79f1e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -987,7 +987,7 @@ void DocAccessible::ElementStateChanged(dom::Document* aDocument,

  if (aStateMask.HasState(dom::ElementState::INVALID)) {
    RefPtr<AccEvent> event =
        new AccStateChangeEvent(accessible, states::INVALID, true);
        new AccStateChangeEvent(accessible, states::INVALID);
    FireDelayedEvent(event);
  }

+30 −0
Original line number Diff line number Diff line
@@ -452,3 +452,33 @@ addAccessibleTask(
  },
  { topLevel: true, iframe: true, remoteIframe: true, chrome: true }
);

/**
 * Test invalid state determined via DOM.
 */
addAccessibleTask(
  `<input type="email" id="email">`,
  async function(browser, docAcc) {
    const email = findAccessibleChildByID(docAcc, "email");
    info("Focusing email");
    let focused = waitForEvent(EVENT_FOCUS, email);
    email.takeFocus();
    await focused;
    info("Typing a");
    let invalidChanged = waitForStateChange(email, STATE_INVALID, true);
    EventUtils.sendString("a");
    await invalidChanged;
    testStates(email, STATE_INVALID);
    info("Typing @b");
    invalidChanged = waitForStateChange(email, STATE_INVALID, false);
    EventUtils.sendString("@b");
    await invalidChanged;
    testStates(email, 0, 0, STATE_INVALID);
    info("Typing backspace");
    invalidChanged = waitForStateChange(email, STATE_INVALID, true);
    EventUtils.synthesizeKey("KEY_Backspace");
    await invalidChanged;
    testStates(email, STATE_INVALID);
  },
  { chrome: true, topLevel: true, remoteIframe: true }
);