2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
5 <button id=
"button">Button
</button>
6 <label id=
"label" for=
"button" style=
"display:none" aria-label=
"AriaLabel">Label
</label>
10 var axButton
= accessibilityController
.accessibleElementById("button");
12 // Get the AXObject for the label indirectly, even though it's display:none.
13 // Ensure that it's valid.
14 var axLabel
= axButton
.titleUIElement();
15 assert_equals(axLabel
.isValid
, true);
16 assert_equals(axLabel
.deprecatedDescription
, 'AXDescription: AriaLabel');
18 // Now un-hide the label.
19 var label
= document
.getElementById('label');
20 label
.style
.display
= "block";
22 // Ensure that the previous AXObject we had for the label is now invalid, but if
23 // we fetch an AXObject for it, we get a new valid object.
24 var axLabel2
= axButton
.titleUIElement();
25 assert_equals(axLabel
.isValid
, false);
26 assert_equals(axLabel2
.isValid
, true);
27 assert_equals(axLabel2
.deprecatedDescription
, 'AXDescription: AriaLabel');
28 assert_equals(axLabel
.isEqual(axLabel2
), false);
30 // Now hide the label again.
31 label
.style
.display
= "none";
33 // Check once more: the second AXObject is now invalid, but if we fetch
34 // an AXObject for the label a third time, we get a valid object again.
35 var axLabel3
= axButton
.titleUIElement();
36 assert_equals(axLabel
.isValid
, false);
37 assert_equals(axLabel2
.isValid
, false);
38 assert_equals(axLabel3
.isValid
, true);
39 assert_equals(axLabel3
.deprecatedDescription
, 'AXDescription: AriaLabel');
40 assert_equals(axLabel
.isEqual(axLabel3
), false);
41 assert_equals(axLabel2
.isEqual(axLabel3
), false);
42 }, "Accessibility objects for display:none elements");
44 if (window
.testRunner
)
45 document
.getElementById('button').style
.display
= 'none';