act-rules / act-rules.github.io

Accessibility conformance testing rules for HTML
https://act-rules.github.io/
Other
136 stars 68 forks source link

Draft Stateful New Rule: Status Messages are Announced to User #2045

Open tbostic32 opened 1 year ago

tbostic32 commented 1 year ago

The task force is currently drafting up changes that may be made in the next version of the ACT format. The rule below shows some examples of new features we have discussed including in the new format as a way to begin discussions. For this rule, the main discussion points are given below:

Applicability

For each [HTML element] containing [visible text], where this text appeared after the [activation] of an [HTML element] with one of the following roles:

Exceptions (NEW SECTION! SEE COMMENTS ABOVE)

Expectation

Each test target must meet one of the following criteria:

Assumptions

There are no assumptions.

Accessibility Support

There are no accessibility support issues known.

Background

The list of applicable semantic roles is derived by taking all the ARIA 1.1 roles that:

The Exceptions in the applicability are derived from the WCAG 2.1. definition of status messages

Test Cases

Passed

Passed Example 1

A success status message becomes visible after successfully completing the form. The status message is available to AT through the use of role=status.

<html lang="en">
  <head></head>
  <body>
    <form id="example_form">
      <label for="username">Username</label>
      <input type="text" id="username"/>
      <input type="submit" id="submit"/>
    </form>
    <p role="status" id="submit_message"></p>
    <script>
      // Handler for sending success notification
      let form = document.querySelector('#example_form');
      let username = document.querySelector('#username');
      let submit = document.querySelector('#submit');
      let alert = document.querySelector('#submit_message');

      form.addEventListener('submit', function(event) {
        event.preventDefault();
        if(username.value.length > 0) {
          alert.textContent = "Success";
        }
      });

      let actionList = [
        () => {username.value = 'W3C_User';},
        () => {submit.click()}
      ]
      let actionListIndex = 0;

      document.addEventListener('acttfNextAction', (event) => {
        if(actionListIndex < actionList.length){
          actionList[actionListIndex++]();
        }
        else {
          event.preventDefault(); // Return no further actions available
        }
      });
    </script>
  </body>
</html>

Passed Example 2

Status messages about the progress of the NASA launch progress are displayed and available to AT through the use of role="log".

<html lang="en">
  <head></head>
  <body>
    <h1>NASA Launch Progress</h1>
    <div id="updateLog" role="log">
      <h2 id="logHeading">Launch Updates</h2>
      <ul id="log-entries">
      </ul>
    </div>
    <script>
      // Simulate launch updates
      let launchSteps = [
        'Fuelling Boosters',
        'Checking all checklists',
        'Buckling In Astronauts',
        'Initiating Countdown',
        'Launching!'];
      let logIndex = 0;
      let logEntries = document.querySelector('#log-entries');
      setInterval(() => {
        let li = document.createElement('LI');
        li.textContent = `${launchSteps[logIndex++ % launchSteps.length]}`;
        logEntries.prepend(li);
      }, 3000);
    </script>
  </body>
</html>

Failed

Failed Example 1

A success status message becomes visible after successfully completing the form, but the status message is not available to AT since no live region role or aria-live attribute is used.

<html lang="en">
  <head></head>
  <body>
    <form id="example_form">
      <label for="username">Username</label>
      <input type="text" id="username"/>
      <input type="submit" id="submit"/>
    </form>
    <p id="submit_message"></p>
    <script>
      // Handler for sending success notification
      let form = document.querySelector('#example_form');
      let username = document.querySelector('#username');
      let submit = document.querySelector('#submit');
      let alert = document.querySelector('#submit_message');

      form.addEventListener('submit', function(event) {
        event.preventDefault();
        if(username.value.length > 0) {
          alert.textContent = "Success";
        }
      });

      let actionList = [
        () => {username.value = 'W3C_User';},
        () => {submit.click()}
      ]
      let actionListIndex = 0;

      document.addEventListener('acttfNextAction', (event) => {
        if(actionListIndex < actionList.length){
          actionList[actionListIndex++]();
        }
        else {
          event.preventDefault(); // Return no further actions available
        }
      });
    </script>
  </body>
</html>

Failed Example 2

Status messages about the progress of the NASA launch progress are displayed as [visible text], but are not available to AT since no live region role or aria-live attribute is used.

<html lang="en">
  <head></head>
  <body>
    <h1>NASA Launch Progress</h1>
    <div id="updateLog" role="log">
      <h2 id="logHeading">Launch Updates</h2>
      <ul id="log-entries">
      </ul>
    </div>
    <script>
      // Simulate launch updates
      let launchSteps = [
        'Fuelling Boosters',
        'Checking all checklists',
        'Buckling In Astronauts',
        'Initiating Countdown',
        'Launching!'];
      let logIndex = 0;
      let logEntries = document.querySelector('#log-entries');
      setInterval(() => {
        let li = document.createElement('LI');
        li.textContent = `${launchSteps[logIndex++ % launchSteps.length]}`;
        logEntries.prepend(li);
      }, 3000);
    </script>
  </body>
</html>

Inapplicable

Inapplicable Example 1

The example shows updates to stock, which falls under the Not a Status Message exception.

<html lang="en">
  <head></head>
  <body>
    <h1>Stock Information</h1>
    <div id="updateLog" role="log">
      <h2 id="logHeading">Stock Updates</h2>
      <ul id="log-entries">
      </ul>
    </div>
    <script>
      // Simulate stock updates
      let stockUpdates = [
        'UP',
        'DOWN',
        'PLATEAUING',
        'SIDEWAYS'
      ];
      let logIndex = 0;
      let logEntries = document.querySelector('#log-entries');
      setInterval(() => {
        let li = document.createElement('LI');
        li.textContent = `Stock is currently ${stockUpdates[logIndex++ % stockUpdates.length]}`;
        logEntries.prepend(li);
      }, 3000);
    </script>
  </body>
</html>

Inapplicable Example 2

Focus is placed on the status message when the form is submitted, which falls under the Text Receives Focus exception to the applicability.

<html lang="en">
  <head></head>
  <body>
    <form id="example_form">
      <label for="username">Username</label>
      <input type="text" id="username"/>
      <input type="submit" id="submit"/>
    </form>
    <p tabindex="0" id="submit_message"></p>
    <script>
      // Handler for sending success notification
      let form = document.querySelector('#example_form');
      let username = document.querySelector('#username');
      let submit = document.querySelector('#submit');
      let alert = document.querySelector('#submit_message');

      form.addEventListener('submit', function(event) {
        event.preventDefault();
        if(username.value.length > 0) {
          alert.textContent = "Success";
          alert.focus();
        }
      });

      let actionList = [
        () => {username.value = 'W3C_User';},
        () => {submit.click()}
      ]
      let actionListIndex = 0;

      document.addEventListener('acttfNextAction', (event) => {
        if(actionListIndex < actionList.length){
          actionList[actionListIndex++]();
        }
        else {
          event.preventDefault(); // Return no further actions available
        }
      });
    </script>
  </body>
</html>
tbostic32 commented 1 year ago

While we could hold the conversation here, there are so many discussion points that I think it would be best if we could put them in the discussion here (https://github.com/act-rules/act-rules.github.io/discussions/2046) where it will be more organized.