Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AX: Add support for ARIA 1.1 attribute 'aria-modal' for dialog and al…
…ertdialog

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
  • Loading branch information
Nan Wang committed Nov 3, 2015
1 parent fe34914 commit 7280502
Show file tree
Hide file tree
Showing 11 changed files with 449 additions and 0 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
2015-11-02 Nan Wang <n_wang@apple.com>

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.

* 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.

2015-11-02 Brady Eidson <beidson@apple.com>

Modern IDB: IBDObjectStore.delete() support.
Expand Down
19 changes: 19 additions & 0 deletions LayoutTests/accessibility/aria-modal-expected.txt
@@ -0,0 +1,19 @@
This tests that aria-modal on dialog makes other elements inert.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS backgroundAccessible() is false
PASS backgroundAccessible() is true
PASS backgroundAccessible() is false
PASS okBtn.isIgnored is false
PASS backgroundAccessible() is true
PASS backgroundAccessible() is true
PASS backgroundAccessible() is false
PASS backgroundAccessible() is true
PASS successfullyParsed is true

TEST COMPLETE
Other page content with a dummy focusable element

Display a dialog
20 changes: 20 additions & 0 deletions LayoutTests/accessibility/aria-modal-multiple-dialogs-expected.txt
@@ -0,0 +1,20 @@
This tests that aria-modal works correctly on multiple dialogs

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS backgroundAccessible() is true
PASS backgroundAccessible() is false
PASS dialog1Accessible() is true
PASS backgroundAccessible() is false
PASS dialog1Accessible() is false
PASS closeBtn.isIgnored is false
PASS backgroundAccessible() is false
PASS dialog1Accessible() is true
PASS backgroundAccessible() is true
PASS successfullyParsed is true

TEST COMPLETE
Other page content with a dummy focusable element

Display a dialog
94 changes: 94 additions & 0 deletions LayoutTests/accessibility/aria-modal-multiple-dialogs.html
@@ -0,0 +1,94 @@
<!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>
85 changes: 85 additions & 0 deletions LayoutTests/accessibility/aria-modal.html
@@ -0,0 +1,85 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>

<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('show'); return false;" href="#" role="button" id="displayBtn">Display a dialog</a></p>
</div>

<div role="dialog" aria-modal="true" aria-labelledby="myDialog" id="box" class="box-hidden" tabindex="-1">
<h3 id="myDialog">Just an example.</h3>
<button id="ok" onclick="toggleDialog('hide');" class="close-button">OK</button>
<button onclick="toggleDialog('hide');" class="close-button">Cancel</button>
</div>


<script>

description("This tests that aria-modal on dialog makes other elements inert.");

if (window.accessibilityController) {
// Background should be unaccessible after loading, since the
// dialog is displayed and aria-modal=true.
shouldBeFalse("backgroundAccessible()");

// Close the dialog, background should be accessible.
document.getElementById("ok").click();
shouldBeTrue("backgroundAccessible()");

// Click the display button, dialog shows and background becomes unaccessible.
document.getElementById("displayBtn").click();
shouldBeFalse("backgroundAccessible()");
var okBtn = accessibilityController.accessibleElementById("ok");
shouldBeFalse("okBtn.isIgnored");

// Test the case that aria-modal=true when dialog is hidden won't affect other objects.
// 1. Dialog not rendered
document.getElementById("ok").click();
document.getElementById("box").setAttribute("aria-modal", "true");
shouldBeTrue("backgroundAccessible()");
// 2. Dialog is aria hidden
document.getElementById("displayBtn").click();
document.getElementById("box").setAttribute("aria-hidden", "true");
shouldBeTrue("backgroundAccessible()");
document.getElementById("box").setAttribute("aria-hidden", "false");
shouldBeFalse("backgroundAccessible()");

// Test modal dialog is removed from DOM tree.
var dialog = document.getElementById("box");
dialog.parentNode.removeChild(dialog);
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 toggleDialog(sh) {
dialog = document.getElementById("box");
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>
42 changes: 42 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,45 @@
2015-11-02 Nan Wang <n_wang@apple.com>

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.

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:

2015-11-02 Brady Eidson <beidson@apple.com>

Modern IDB: IBDObjectStore.delete() support.
Expand Down

0 comments on commit 7280502

Please sign in to comment.