test_stale.html (3092B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Stale state testing</title> 5 <link rel="stylesheet" type="text/css" 6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 7 8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 9 10 <script type="application/javascript" 11 src="../common.js"></script> 12 <script type="application/javascript" 13 src="../role.js"></script> 14 <script type="application/javascript" 15 src="../states.js"></script> 16 <script type="application/javascript" 17 src="../events.js"></script> 18 19 <script type="application/javascript"> 20 function addChild(aContainerID) { 21 this.containerNode = getNode(aContainerID); 22 this.childNode = null; 23 24 this.eventSeq = [ 25 new invokerChecker(EVENT_REORDER, this.containerNode), 26 ]; 27 28 this.invoke = function addChild_invoke() { 29 this.childNode = document.createElement("div"); 30 // Note after bug 646216, a sole div without text won't be accessible 31 // and would not result in an embedded character. 32 // Therefore, add some text. 33 this.childNode.textContent = "hello"; 34 this.containerNode.appendChild(this.childNode); 35 }; 36 37 this.finalCheck = function addChild_finalCheck() { 38 // no stale state should be set 39 testStates(this.childNode, 0, 0, 0, EXT_STATE_STALE); 40 }; 41 42 this.getID = function addChild_getID() { 43 return "add child for " + prettyName(aContainerID); 44 }; 45 } 46 47 function removeChildChecker(aInvoker) { 48 this.type = EVENT_HIDE; 49 this.__defineGetter__("target", function() { return aInvoker.child; }); 50 51 this.check = function removeChildChecker_check() { 52 // stale state should be set 53 testStates(aInvoker.child, 0, EXT_STATE_STALE); 54 }; 55 } 56 57 function removeChild(aContainerID) { 58 this.containerNode = getNode(aContainerID); 59 this.child = null; 60 61 this.eventSeq = [ 62 new removeChildChecker(this), 63 ]; 64 65 this.invoke = function removeChild_invoke() { 66 var childNode = this.containerNode.firstChild; 67 this.child = getAccessible(childNode); 68 69 this.containerNode.removeChild(childNode); 70 }; 71 72 this.getID = function removeChild_getID() { 73 return "remove child from " + prettyName(aContainerID); 74 }; 75 } 76 77 // gA11yEventDumpToConsole = true; //debugging 78 79 var gQueue = null; 80 function doTest() { 81 gQueue = new eventQueue(); 82 83 gQueue.push(new addChild("container")); 84 gQueue.push(new removeChild("container")); 85 86 gQueue.invoke(); // will call SimpleTest.finish() 87 } 88 89 SimpleTest.waitForExplicitFinish(); 90 addA11yLoadEvent(doTest); 91 </script> 92 </head> 93 94 <body role=""> 95 96 <a target="_blank" 97 title="Expose stale state on accessibles unattached from tree" 98 href="https://bugzilla.mozilla.org/show_bug.cgi?id=676267">Mozilla Bug 676267</a> 99 100 <p id="display"></p> 101 <div id="content" style="display: none"></div> 102 <pre id="test"> 103 </pre> 104 105 <div id="container"></div> 106 107 </body> 108 </html>