blob: 5213ea5783ba12d7440f9e4f75c4717b71d9c68a [file] [log] [blame]
<script src="../resources/gc.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
Accessibility Object Model
<div id="button1" role="button">Click</div>
test(function(t) {
}, "Make sure that Accessibility Object Model is enabled");
promise_test(async t => {
const element = document.getElementById("button1");
let computedAXNode = await getComputedAccessibleNode(element);
assert_true(computedAXNode != null);
}, 'Ensure that a non null value is returned from getComputedAccessibleNode');
promise_test(async t => {
const element = document.getElementById("button1");
let computedAXNode1 = await getComputedAccessibleNode(element);
let computedAXNode2 = await getComputedAccessibleNode(element);
assert_true(computedAXNode1 === computedAXNode2);
}, "Multiple calls to getComputedAccessibleNode will return the same node.");
<div id="button2" role="button" aria-label="axButton">Click</div>
promise_test(async t => {
var button1 = document.getElementById("button1");
let button1CAXNode = await getComputedAccessibleNode(button1);
assert_equals(, "Click");
assert_equals(button1CAXNode.role, "button"); = "none";
var button2 = document.getElementById("button2");
let button2CAXNode = await getComputedAccessibleNode(button2);
assert_equals(, "axButton");
assert_equals(button2CAXNode.role, "button");
// As button1 has no node in the accessibility tree anymore, assert that the
// its previously retrieved computed accessible node has had its attributes
// nullified.
assert_equals(, null);
assert_equals(button1CAXNode.role, null);
}, "Deleting nodes from the accessibility tree will not cause a crash, and properties on any references to a deleted computed accessible node have been nullified.");
<div id="radio1" role="radio">Radio 1</div>
<div id="radio2" role="radio">Radio 2</div>
promise_test(async function(test) {
var radio1 = document.getElementById("radio1");
var caxNode1 = await window.getComputedAccessibleNode(radio1);
var radio2 = document.getElementById("radio2");
var caxNode2 = await window.getComputedAccessibleNode(radio2);
radio1.innerHTML = "pizza";
radio2.innerHTML = "tacos";
// ComputedAccessibleNode for this element has not been updated so should
// only reflect the name at the time of its request.
assert_equals(, "Radio 1");
assert_equals(, "Radio 2");
// Manually refresh the node and check that all references to
// ComputedAccessibleNodes have been updated.
await caxNode1.ensureUpToDate();
assert_equals(, "pizza");
assert_equals(, "tacos");
radio1.setAttribute("aria-label", "pasta");
assert_equals(, "pizza");
await caxNode1.ensureUpToDate();
assert_equals(, "pasta");
}, "ComputedAccessibleNode.ensureUpToDate");