blob: 99bb50e5b448770b454758d771eb7e0003bcd6b9 [file] [log] [blame]
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<button id="button">Button</button>
<label id="label" for="button" style="display:none" aria-label="AriaLabel">Label</label>
test(function(t) {
var axButton = accessibilityController.accessibleElementById("button");
// Get the AXObject for the label indirectly, even though it's display:none.
// Ensure that it's valid.
var axLabel = axButton.nameElementAtIndex(0);
assert_equals(axLabel.isValid, true);
assert_equals(axLabel.role, 'AXRole: AXLabel');
// Now un-hide the label.
var label = document.getElementById('label'); = "block";
// Ensure that the previous AXObject we had for the label is now invalid, but if
// we fetch an AXObject for it, we get a new valid object.
var axLabel2 = axButton.nameElementAtIndex(0);
assert_equals(axLabel.isValid, false);
assert_equals(axLabel2.isValid, true);
assert_equals(, 'AriaLabel');
assert_equals(axLabel.isEqual(axLabel2), false);
// Now hide the label again. = "none";
// Check once more: the second AXObject is now invalid, but if we fetch
// an AXObject for the label a third time, we get a valid object again.
var axLabel3 = axButton.nameElementAtIndex(0);
assert_equals(axLabel.isValid, false);
assert_equals(axLabel2.isValid, false);
assert_equals(axLabel3.isValid, true);
assert_equals(axLabel3.role, 'AXRole: AXLabel');
assert_equals(axLabel.isEqual(axLabel3), false);
assert_equals(axLabel2.isEqual(axLabel3), false);
}, "Accessibility objects for display:none elements");