HTML role attribute tests

The following are a few tests for the role attribute.

Test 1: is the role attribute conveyed?

This tests ensures that the role attribute is conveyed. The button role was selected since it is known to be widely supported. To pass, the element must be conveyed as a button in screen readers and actionable in voice control software.

Action 1

Test 2: are fallback roles supported?

This tests ensures that fallback roles are supported. A nonsensical role was selected as the first value since it should never be supported, and the button role was selected as a fallback role since it is known to be widely supported. To pass, the element must be conveyed as a button in screen readers and actionable in voice control software.

Action 2

Test 3: are changes to the role processed?

This tests ensures that changes to the role are processed. The image role was chosen for the initial role since it is known to be widely supported, and the button role was selected as the new dynamic role since it is also known to be widely supported. The role should be changed 1 second after page load and a success message will display under the button when the role has changed.

For screen readers: to pass, the element must be conveyed as a button after the role has been changed.

For voice control: to pass, the element must be actionable, either though the command to click a role name or by the show numbers command.

Action 3
Role has not changed yet

Test 4: is the screen reader caret lost when the role of a container changes?

The containing role begins as 'note' and changes to 'region'. The testing procedure follows:

  1. activate the button to trigger the role change in 10 seconds
  2. navigate within the following container to the line of text the says "wait here"
  3. after the role has changed, navigate to the next line of text.
  4. The test passes if the screen reader announces "target text". If something else is found, that is an indication that the browse caret was lost.

test start

wait here

target text

Role has not changed yet

End tests