test_descrchange.html (4542B)
1 <html> 2 3 <head> 4 <title>Accessible description change event testing</title> 5 6 <link rel="stylesheet" type="text/css" 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.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="../role.js"></script> 18 <script type="application/javascript" 19 src="../states.js"></script> 20 21 <script type="application/javascript"> 22 let PromEvents = {}; 23 Services.scriptloader.loadSubScript( 24 "chrome://mochitests/content/a11y/accessible/tests/mochitest/promisified-events.js", 25 PromEvents); 26 27 // ////////////////////////////////////////////////////////////////////////// 28 // Invokers 29 30 function setAttr(aID, aAttr, aValue, aChecker) { 31 this.eventSeq = [ aChecker ]; 32 this.invoke = function setAttr_invoke() { 33 getNode(aID).setAttribute(aAttr, aValue); 34 }; 35 36 this.getID = function setAttr_getID() { 37 return "set attr '" + aAttr + "', value '" + aValue + "'"; 38 }; 39 } 40 41 // ////////////////////////////////////////////////////////////////////////// 42 // Do tests 43 44 // gA11yEventDumpToConsole = true; // debuggin 45 46 var gQueue = null; 47 async function doTests() { 48 gQueue = new eventQueue(); 49 // Later tests use await. 50 let queueFinished = new Promise(resolve => { 51 gQueue.onFinish = function() { 52 resolve(); 53 return DO_NOT_FINISH_TEST; 54 }; 55 }); 56 57 gQueue.push(new setAttr("tst1", "aria-describedby", "display", 58 new invokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1"))); 59 gQueue.push(new setAttr("tst1", "title", "title", 60 new unexpectedInvokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1"))); 61 62 // A title has lower priority over text content. There should be no name change event. 63 gQueue.push(new setAttr("tst2", "title", "title", 64 new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst2"))); 65 66 gQueue.invoke(); 67 await queueFinished; 68 // Tests beyond this point use await rather than eventQueue. 69 70 const describedBy = getNode("describedBy"); 71 const description = getNode("description"); 72 let descChanged = PromEvents.waitForEvent( 73 EVENT_DESCRIPTION_CHANGE, 74 describedBy 75 ); 76 info("Changing text of aria-describedby target"); 77 description.textContent = "d2"; 78 await descChanged; 79 descChanged = PromEvents.waitForEvent( 80 EVENT_DESCRIPTION_CHANGE, 81 describedBy 82 ); 83 info("Adding node to aria-describedby target"); 84 description.innerHTML = '<p id="descriptionChild">d3</p>'; 85 await descChanged; 86 descChanged = PromEvents.waitForEvent( 87 EVENT_DESCRIPTION_CHANGE, 88 describedBy 89 ); 90 info("Changing text of aria-describedby target's child"); 91 getNode("descriptionChild").textContent = "d4"; 92 await descChanged; 93 94 const lateDescribedBy = getNode("lateDescribedBy"); 95 descChanged = PromEvents.waitForEvent( 96 EVENT_DESCRIPTION_CHANGE, 97 lateDescribedBy 98 ); 99 info("Setting aria-describedby"); 100 lateDescribedBy.setAttribute("aria-describedby", "lateDescription"); 101 await descChanged; 102 descChanged = PromEvents.waitForEvent( 103 EVENT_DESCRIPTION_CHANGE, 104 lateDescribedBy 105 ); 106 info("Changing text of late aria-describedby target's child"); 107 getNode("lateDescriptionChild").textContent = "d2"; 108 await descChanged; 109 110 SimpleTest.finish(); 111 } 112 113 SimpleTest.waitForExplicitFinish(); 114 addA11yLoadEvent(doTests); 115 </script> 116 </head> 117 118 <body> 119 120 <a target="_blank" 121 href="https://bugzilla.mozilla.org/show_bug.cgi?id=991969" 122 title="Event not fired when description changes"> 123 Bug 991969 124 </a> 125 126 <p id="display"></p> 127 <div id="content" style="display: none"></div> 128 <pre id="test"> 129 </pre> 130 131 <button id="tst1">btn1</button> 132 <button id="tst2">btn2</button> 133 134 <div id="describedBy" aria-describedby="description"></div> 135 <div id="description">d1</div> 136 137 <div id="lateDescribedBy"></div> 138 <div id="lateDescription"><p id="lateDescriptionChild">d1</p></div> 139 140 <div id="eventdump"></div> 141 </body> 142 </html>