blob: 828ecd151fca08f705ac51469e7fa987289b9ac8 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body id="body">
<div role="group" id="group" tabindex="0">group</div>
<div role="button" id="button" tabindex="0">button</div>
<div role="tab" id="tab" tabindex="0">tab button</div>
<div role="radio" id="radio" tabindex="0">radio</div>
<div role="checkbox" id="checkbox" tabindex="0">checkbox</div>
<div role="menuitem" id="menuitem" tabindex="0">menu item</div>
<div role="menuitemcheckbox" id="menuitemcheckbox" tabindex="0">menu item checkbox</div>
<div role="menuitemradio" id="menuitemradio" tabindex="0">menu item radio</div>
<div role="listitem" id="listitem" tabindex="0">list item</div>
<div role="button" id="button2" tabindex="0"><div><button id="subbutton"></div></div>
<p id="description"></p>
<div id="console"></div>
<script>
document.getElementById("body").onmousedown = handlePress;
var pressCount = 0;
var eventSrcElement;
function handlePress(e) {
eventSrcElement = e.srcElement;
if (pressCount == 0)
shouldBeTrue("eventSrcElement == document.getElementById('group')");
else if (pressCount == 1)
shouldBeTrue("eventSrcElement == document.getElementById('button')");
else if (pressCount == 2)
shouldBeTrue("eventSrcElement == document.getElementById('tab')");
else if (pressCount == 3)
shouldBeTrue("eventSrcElement == document.getElementById('radio')");
else if (pressCount == 4)
shouldBeTrue("eventSrcElement == document.getElementById('checkbox')");
else if (pressCount == 5)
shouldBeTrue("eventSrcElement == document.getElementById('menuitem')");
else if (pressCount == 6)
shouldBeTrue("eventSrcElement == document.getElementById('menuitemcheckbox')");
else if (pressCount == 7)
shouldBeTrue("eventSrcElement == document.getElementById('menuitemradio')");
else if (pressCount == 8)
shouldBeTrue("eventSrcElement == document.getElementById('listitem')");
else if (pressCount == 9)
shouldBeTrue("eventSrcElement == document.getElementById('subbutton')");
pressCount++;
}
description("This tests that when certain control type elements are pressed, a valid event is sent that references the right element.");
var items = new Array("group", "button", "tab", "radio", "checkbox", "menuitem", "menuitemcheckbox", "menuitemradio", "listitem", "button2");
var length = items.length;
if (window.accessibilityController) {
jsTestIsAsync = true;
// AXPress on Mac is async, let's give it some delay and do it recursively.
accessibilityPress(0);
}
function accessibilityPress(k) {
if (k == length)
finishJSTest();
accessibilityController.accessibleElementById(items[k]).press();
setTimeout(function() {
accessibilityPress(k+1);
}, 10);
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>