test_bug420863.html (2899B)
1 <!DOCTYPE html> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=420863 5 --> 6 <head> 7 <title>Table indexes chrome tests</title> 8 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 11 12 <script type="application/javascript" 13 src="common.js"></script> 14 <script type="application/javascript" 15 src="events.js"></script> 16 <script type="application/javascript" 17 src="actions.js"></script> 18 19 <script type="application/javascript"> 20 var gClickHandler = null; 21 22 function doTest() { 23 // Actions should be exposed on any accessible having related DOM node 24 // with registered 'click' event handler. 25 26 // //////////////////////////////////////////////////////////////////////// 27 // generic td 28 var td1Acc = getAccessible("td1"); 29 if (!td1Acc) { 30 SimpleTest.finish(); 31 return; 32 } 33 34 is(td1Acc.actionCount, 0, 35 "Simple table cell shouldn't have any actions"); 36 37 // //////////////////////////////////////////////////////////////////////// 38 // one td with 'onclick' attribute and one with registered click handler 39 var td3Node = getNode("td3"); 40 41 // register 'click' event handler 42 gClickHandler = { 43 handleEvent: function handleEvent() { 44 }, 45 }; 46 td3Node.addEventListener("click", gClickHandler); 47 48 // check actions 49 var actionsArray = [ 50 { 51 ID: "td2", // "onclick" attribute 52 actionName: "click", 53 actionIndex: 0, 54 events: CLICK_EVENTS, 55 }, 56 { 57 ID: td3Node, 58 actionName: "click", 59 actionIndex: 0, 60 events: CLICK_EVENTS, 61 checkOnClickEvent: function check() { 62 // unregister click event handler 63 this.ID.removeEventListener("click", gClickHandler); 64 65 // check actions 66 is(getAccessible(this.ID).actionCount, 0, 67 "td3 shouldn't have actions"); 68 }, 69 }, 70 ]; 71 72 testActions(actionsArray); // will call SimpleTest.finish() 73 } 74 75 SimpleTest.waitForExplicitFinish(); 76 addA11yLoadEvent(doTest); 77 </script> 78 </head> 79 <body> 80 81 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420863" 82 title="If an HTML element has an onClick attribute, expose its click action on the element rather than its child text leaf node." 83 target="_blank">Mozilla Bug 420863</a> 84 <p id="display"></p> 85 <div id="content" style="display: none"></div> 86 <pre id="test"> 87 </pre> 88 89 <table> 90 <tr> 91 <td id="td1">Can't click this cell</td> 92 <td onclick="gTdClickAttr = true;" 93 id="td2">Cell with 'onclick' attribute</td> 94 <td id="td3">Cell with registered 'click' event handler</td> 95 </tr> 96 </table> 97 98 </body> 99 </html>