haikuwebkit/LayoutTests/accessibility/aria-modal-multiple-dialogs...

94 lines
3.3 KiB
HTML
Raw Permalink Normal View History

AX: Add support for ARIA 1.1 attribute 'aria-modal' for dialog and alertdialog https://bugs.webkit.org/show_bug.cgi?id=138566 Reviewed by Chris Fleizach. Source/WebCore: Added support for aria-modal attribute on dialog/alertdialog roles. When modal dialog is displayed, all other contents will be unaccessible. Tests: accessibility/aria-modal-multiple-dialogs.html accessibility/aria-modal.html * accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::AXObjectCache): (WebCore::AXObjectCache::~AXObjectCache): (WebCore::AXObjectCache::findAriaModalNodes): (WebCore::AXObjectCache::updateCurrentAriaModalNode): (WebCore::AXObjectCache::isNodeVisible): (WebCore::AXObjectCache::ariaModalNode): (WebCore::AXObjectCache::focusedImageMapUIElement): (WebCore::AXObjectCache::remove): (WebCore::AXObjectCache::handleAttributeChanged): (WebCore::AXObjectCache::handleAriaModalChange): (WebCore::AXObjectCache::labelChanged): * accessibility/AXObjectCache.h: (WebCore::AXObjectCache::handleActiveDescendantChanged): (WebCore::AXObjectCache::handleAriaExpandedChange): (WebCore::AXObjectCache::handleAriaRoleChanged): (WebCore::AXObjectCache::handleAriaModalChange): (WebCore::AXObjectCache::handleFocusedUIElementChanged): (WebCore::AXObjectCache::handleScrollbarUpdate): (WebCore::AXObjectCache::handleAttributeChanged): * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::ariaCurrentState): (WebCore::AccessibilityObject::isAriaModalDescendant): (WebCore::AccessibilityObject::ignoredFromARIAModalPresence): (WebCore::AccessibilityObject::hasTagName): (WebCore::AccessibilityObject::defaultObjectInclusion): * accessibility/AccessibilityObject.h: * html/HTMLAttributeNames.in: LayoutTests: * accessibility/aria-modal-expected.txt: Added. * accessibility/aria-modal-multiple-dialogs-expected.txt: Added. * accessibility/aria-modal-multiple-dialogs.html: Added. * accessibility/aria-modal.html: Added. Canonical link: https://commits.webkit.org/169020@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-11-03 01:52:38 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<style>
.box-hidden {
display: none;
}
</style>
<body id="body">
<div id="bg">
<p id="bgContent">Other page content with <a href="#">a dummy focusable element</a></p>
<p><a onclick="toggleDialog(document.getElementById('box'),'show'); return false;" href="#" role="button" id="displayBtn">Display a dialog</a></p>
</div>
<div role="dialog" aria-labelledby="myDialog" id="box" class="box-hidden" tabindex="-1">
<h3 id="myDialog">Just an example.</h3>
<button id="ok" onclick="toggleDialog(document.getElementById('box'),'hide');" class="close-button">OK</button>
<button onclick="toggleDialog(document.getElementById('box2'),'show');" id="new">New</button>
</div>
<div role="dialog" aria-labelledby="myDialog2" id="box2" class="box-hidden" tabindex="-1">
<h3 id="myDialog2">Another dialog.</h3>
<button id="close" onclick="toggleDialog(document.getElementById('box2'),'hide');" class="close-button">Close</button>
</div>
<script>
description("This tests that aria-modal works correctly on multiple dialogs");
if (window.accessibilityController) {
// Background should be accessible after loading.
shouldBeTrue("backgroundAccessible()");
// Click the display button, dialog1 shows and background becomes unaccessible.
document.getElementById("displayBtn").click();
shouldBeFalse("backgroundAccessible()");
shouldBeTrue("dialog1Accessible()");
// Click the new button, dialog2 shows and background/dialog1 should both be unaccessible.
document.getElementById("new").click();
shouldBeFalse("backgroundAccessible()");
shouldBeFalse("dialog1Accessible()");
var closeBtn = accessibilityController.accessibleElementById("close");
shouldBeFalse("closeBtn.isIgnored");
// Close dialog2, dialog1 should become accessible but not the background
document.getElementById("close").click();
shouldBeFalse("backgroundAccessible()");
shouldBeTrue("dialog1Accessible()");
// Close dialog1, background should be accessible.
document.getElementById("ok").click();
shouldBeTrue("backgroundAccessible()");
}
function backgroundAccessible() {
var displayBtn = accessibilityController.accessibleElementById("displayBtn");
var bgContent = accessibilityController.accessibleElementById("bgContent");
if (!displayBtn || !bgContent)
return false;
return !displayBtn.isIgnored && !bgContent.isIgnored;
}
function dialog1Accessible() {
var okBtn = accessibilityController.accessibleElementById("ok");
var newBtn = accessibilityController.accessibleElementById("new");
if (!okBtn || !newBtn)
return false;
return !okBtn.isIgnored && !newBtn.isIgnored;
}
function toggleDialog(dialog, sh) {
if (sh == "show") {
// show the dialog
dialog.style.display = 'block';
dialog.setAttribute("aria-modal", "true");
} else {
dialog.style.display = 'none';
dialog.setAttribute("aria-modal", "false");
}
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>