| <!DOCTYPE HTML> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../../resources/accessibility-helper.js"></script> |
| </head> |
| <body> |
| |
| <button id="button1" onaccessibleclick="accessibleclickCallback(true)">Click</button> |
| <button id="button2">Click</button> |
| <p id="p1"> |
| <button id="button3">Click</button> |
| </p> |
| |
| <ul id="ul"> |
| <li id="li"> |
| <button id="button4">Click</button> |
| </li> |
| </ul> |
| |
| <p id="description"></p> |
| <div id="console"></div> |
| |
| <script> |
| description("This tests accessibility-specific events."); |
| if (window.accessibilityController) { |
| var node; |
| var axNode; |
| var receivedDOMLevel1Event; |
| var receivedAXEvent; |
| var receivedFallbackEvent; |
| |
| testAccessibleClick(); |
| testPreventDefault(); |
| testEventBubbling(); |
| testEventCapturingAndBubbling(); |
| } |
| |
| function accessibleclickCallback(domLevel1) { |
| if (domLevel1) |
| receivedDOMLevel1Event = true; |
| else |
| receivedAXEvent = true; |
| } |
| |
| function testAccessibleClickDOMLevel1() { |
| debug("\nonaccessibleclick attribute support"); |
| axNode = accessibilityController.accessibleElementById("button0"); |
| receivedAXEvent = false; |
| axNode.syncPress(); |
| shouldBeTrue("receivedAXEvent"); |
| } |
| |
| function testAccessibleClick() { |
| debug("\nonaccessibleclick support"); |
| node = document.getElementById("button1"); |
| axNode = accessibilityController.accessibleElementById("button1"); |
| |
| // DOM Level 1 event |
| receiveDOMLevel1Event = false; |
| axNode.syncPress(); |
| shouldBeTrue("receivedDOMLevel1Event"); |
| // DOM Level 2 event |
| receivedAXEvent = false; |
| receivedFallbackEvent = false; |
| node.onaccessibleclick = function() { |
| accessibleclickCallback(); |
| }; |
| node.onclick = function() { |
| receivedFallbackEvent = true; |
| }; |
| axNode.syncPress(); |
| shouldBeTrue("receivedAXEvent"); |
| shouldBeTrue("receivedFallbackEvent"); |
| } |
| |
| function testPreventDefault() { |
| debug("\nTest preventDefault"); |
| node = document.getElementById("button2"); |
| axNode = accessibilityController.accessibleElementById("button2"); |
| |
| receivedAXEvent = false; |
| receivedFallbackEvent = false; |
| node.onaccessibleclick = function(evt) { |
| receivedAXEvent = true; |
| evt.preventDefault(); |
| }; |
| node.onclick = function() { |
| receivedFallbackEvent = true; |
| }; |
| axNode.syncPress(); |
| shouldBeTrue("receivedAXEvent"); |
| shouldBeFalse("receivedFallbackEvent"); |
| } |
| |
| function testEventBubbling() { |
| debug("\nTest event bubbling"); |
| node = document.getElementById("p1"); |
| axNode = accessibilityController.accessibleElementById("button3"); |
| |
| node.onaccessibleclick = function() { |
| receivedAXEvent = true; |
| }; |
| axNode.syncPress(); |
| shouldBeTrue("receivedAXEvent"); |
| } |
| |
| function testEventCapturingAndBubbling() { |
| debug("\nTest event capturing and bubbling"); |
| var ul = document.getElementById("ul"); |
| var li = document.getElementById("li"); |
| var button = document.getElementById("button4"); |
| axNode = accessibilityController.accessibleElementById("button4"); |
| |
| var seq = []; |
| |
| // Add event listeners to each layer |
| ul.addEventListener("accessibleclick", function() { |
| seq.push("AX capture UL"); |
| }, true); |
| ul.addEventListener("accessibleclick", function() { |
| seq.push("AX bubble UL"); |
| }, false); |
| li.addEventListener("accessibleclick", function() { |
| seq.push("AX capture LI"); |
| }, true); |
| li.addEventListener("accessibleclick", function() { |
| seq.push("AX bubble LI"); |
| }, false); |
| button.addEventListener("accessibleclick", function() { |
| seq.push("AX main event listener BUTTON"); |
| }, false); |
| |
| axNode.syncPress(); |
| seq.forEach(function (entry) { |
| debug(entry); |
| }); |
| } |
| |
| </script> |
| <script src="../resources/js-test-post.js"></script> |
| </body> |
| </html> |