blob: 9614b394b674ec274fd4438d09258884df71d203 [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<div id="container">
<div id="hiddenDivContainer" aria-label="hiddenDivContainer">
<div id="hiddenDiv" hidden>
<div>
<button>Button</button>
</div>
</div>
</div>
<div id="invisibleDivContainer" aria-label="invisibleDivContainer">
<div id="invisibleDiv" style="visibility: hidden">
<div>
<button>Button</button>
</div>
</div>
</div>
<div id="emptyDivContainer" aria-label="emptyDivContainer">
<div id="emptyDiv"></div>
</div>
<div id="divWithoutRoleContainer" aria-label="divWithoutRoleContainer">
<div id="divWithoutRole">
<div>
<button>Button</button>
</div>
</div>
</div>
</div>
<div id="console"></div>
<script>
description("This test ensures that a change to accessibilityIsIgnored fires a children changed notification on the parent.");
window.jsTestIsAsync = true;
if (window.testRunner && window.accessibilityController) {
window.setTimeout(finishJSTest, 1000);
testRunner.dumpAsText();
function accessibleElementById(id) {
return accessibilityController.accessibleElementById(id);
}
window.pendingSuccesses = new Set([
'hiddenDivContainer',
'invisibleDivContainer',
'emptyDiv',
'divWithoutRoleContainer',
]);
function gotSuccessfulNotification(id) {
if (!pendingSuccesses.has(id))
debug('Unexpected notification for ' + id);
pendingSuccesses.delete(id);
accessibleElementById(id).removeNotificationListener();
if (pendingSuccesses.size !== 0)
return;
debug('All notifications received successfully.');
document.getElementById('container').hidden = true;
finishJSTest();
}
shouldBeTrue("accessibleElementById('hiddenDivContainer') != null");
shouldBeFalse("accessibleElementById('hiddenDiv') != null");
accessibleElementById('hiddenDivContainer').addNotificationListener(function(notification) {
debug('Got ' + notification + ' notification on hiddenDivContainer');
shouldBe("accessibleElementById('hiddenDivContainer').childrenCount", "1");
gotSuccessfulNotification('hiddenDivContainer');
});
document.getElementById('hiddenDiv').hidden = false;
shouldBeTrue("accessibleElementById('invisibleDivContainer') != null");
shouldBeFalse("accessibleElementById('invisibleDiv') != null");
accessibleElementById('invisibleDivContainer').addNotificationListener(function(notification) {
debug('Got ' + notification + ' notification on invisibleDivContainer');
shouldBe("accessibleElementById('invisibleDivContainer').childrenCount", "1");
gotSuccessfulNotification('invisibleDivContainer');
});
document.getElementById('invisibleDiv').style.visibility = 'visible';
shouldBeTrue("accessibleElementById('emptyDiv') != null");
accessibleElementById('emptyDiv').addNotificationListener(function(notification) {
debug('Got ' + notification + ' notification on emptyDiv');
shouldBe("accessibleElementById('emptyDiv').childrenCount", "1");
gotSuccessfulNotification('emptyDiv');
});
document.getElementById('emptyDiv').innerText = 'Not empty anymore.';
document.getElementById('emptyDiv').offsetLeft;
shouldBeTrue("accessibleElementById('divWithoutRoleContainer') != null");
accessibleElementById('divWithoutRoleContainer').addNotificationListener(function(notification) {
debug('Got ' + notification + ' notification on divWithoutRoleContainer');
shouldBe("accessibleElementById('divWithoutRoleContainer').childrenCount", "1");
gotSuccessfulNotification('divWithoutRoleContainer');
});
document.getElementById('divWithoutRole').setAttribute('role', 'heading');
debug('');
}
</script>
</body>
</html>