blob: 9e412807b663ff007089302497f9c7f09db02cdb [file] [log] [blame]
<!DOCTYPE html>
<html>
<body id="body">
<script src="../../resources/js-test-pre.js"></script>
<div id="content">
<input type="range" min="0" max="100" value="25" step="25" id="slider" onaccessibleincrement="incrementEventCallback(true)" onaccessibledecrement="decrementEventCallback(true)"/>
<input type="text" id="input" onaccessiblefocus="focusEventCallback(true)">
<button id="button" onaccessiblescrollintoview="scrollIntoViewEventCallback(true)">button</button>
<div id="combo" tabindex=0 role="combobox" aria-expanded="false" aria-label="Test" onaccessiblecontextmenu="contextMenuEventCallback(true)">
<div role="listbox">
<div role="option">option 1</div>
</div></div>
<select id="group" multiple="multiple">
<option id="option" onaccessibleselect="selectEventCallback(true)">Option 1</option>
<option>Option 2</option>
</select>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests all accessibility events.");
if (window.accessibilityController) {
jsTestIsAsync = true;
var node;
var axNode;
testIncrementDecrement();
function incrementEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessibleincrement event");
if (domLevel1)
node.removeAttribute("onaccessibleincrement");
}
function decrementEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessibledecrement event");
if (domLevel1)
node.removeAttribute("onaccessibledecrement");
}
function focusEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessiblefocus event");
if (domLevel1) {
node.removeAttribute("onaccessiblefocus");
testFocus();
}
}
function scrollIntoViewEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessiblescrollintoview event");
if (domLevel1)
node.removeAttribute("onaccessiblescrollintoview");
}
function contextMenuEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessiblecontextmenu event");
if (domLevel1)
node.removeAttribute("onaccessiblecontextmenu");
}
function selectEventCallback(domLevel1) {
debug("received " + (domLevel1 ? "DOM Level 1 " : "") + "accessibleselect event");
if (domLevel1)
node.removeAttribute("onaccessibleselect");
}
function testIncrementDecrement() {
debug("\nTest accessibleincrement and accessibledecrement");
node = document.getElementById("slider");
axNode = accessibilityController.accessibleElementById("slider");
// DOM Level 1 events
axNode.increment();
axNode.decrement();
// DOM Level 2 events
node.onaccessibleincrement = function() {
incrementEventCallback();
};
node.onaccessibledecrement = function() {
decrementEventCallback();
};
axNode.increment();
axNode.decrement();
testFocusDOMLevel1();
}
function testFocusDOMLevel1() {
// takeFocus() is async so that this deserves a seperate test
debug("\nTest onaccessiblefocus attribute");
node = document.getElementById("input");
axNode = accessibilityController.accessibleElementById("input");
axNode.takeFocus();
}
function testFocus() {
debug("\nTest accessiblefocus");
// DOM Level 2 event
node = document.getElementById("input");
axNode = accessibilityController.accessibleElementById("input");
node.onaccessiblefocus = function() {
focusEventCallback();
testScrollIntoView();
};
axNode.takeFocus();
}
function testScrollIntoView() {
debug("\nTest accessiblescrollintoview");
node = document.getElementById("button");
axNode = accessibilityController.accessibleElementById("button");
// DOM Level 1 event
axNode.scrollToMakeVisible();
// DOM Level 2 event
node.onaccessiblescrollintoview = function() {
scrollIntoViewEventCallback();
testShowContextMenu();
};
axNode.scrollToMakeVisible();
}
function testShowContextMenu() {
debug("\nTest accessiblecontextmenu");
node = document.getElementById("combo");
axNode = accessibilityController.accessibleElementById("combo");
// DOM Level 1 event
axNode.showMenu();
// DOM Level 2 event
node.onaccessiblecontextmenu = function() {
contextMenuEventCallback();
testSelect();
};
axNode.showMenu();
}
function testSelect() {
debug("\nTest accessibleselect");
node = document.getElementById("option");
axNode = accessibilityController.accessibleElementById("group");
// DOM Level 1 event
axNode.setSelectedChildAtIndex(0);
// DOM Level 2 event
node.onaccessibleselect = function() {
selectEventCallback();
finishJSTest();
}
axNode.setSelectedChildAtIndex(0);
}
} else {
testFailed("Could not load accessibility controller");
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>