test_docload_shutdown.html (4355B)
1 <html> 2 3 <head> 4 <title>Accessible events testing for document</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 11 <script type="application/javascript" 12 src="../../common.js"></script> 13 <script type="application/javascript" 14 src="../../role.js"></script> 15 <script type="application/javascript" 16 src="../../events.js"></script> 17 18 <script type="application/javascript"> 19 // ////////////////////////////////////////////////////////////////////////// 20 // Invokers 21 22 let gDialog; 23 let gDialogDoc; 24 let gRootAcc; 25 let gIframeDoc; 26 27 function openWndShutdownDoc(aURL) { 28 // Get application root accessible. 29 let docAcc = getAccessible(document); 30 while (docAcc) { 31 gRootAcc = docAcc; 32 try { 33 docAcc = docAcc.parent; 34 } catch (e) { 35 ok(false, `Can't get parent for ${prettyName(docAcc)}`); 36 throw e; 37 } 38 } 39 40 this.eventSeq = [ 41 new invokerChecker(EVENT_REORDER, gRootAcc), 42 { 43 type: EVENT_HIDE, 44 get target() { 45 gDialogDoc = gDialog.document; 46 const iframe = gDialogDoc.getElementById("iframe"); 47 gIframeDoc = iframe.contentDocument; 48 return iframe; 49 }, 50 get targetDescr() { 51 return "inner iframe of docload_wnd.html document"; 52 }, 53 }, 54 ]; 55 56 57 this.invoke = () => gDialog = window.browsingContext.topChromeWindow.openDialog(aURL); 58 59 this.finalCheck = () => { 60 const accTree = { 61 role: ROLE_APP_ROOT, 62 children: [ 63 { 64 role: ROLE_CHROME_WINDOW, 65 }, 66 { 67 role: ROLE_CHROME_WINDOW, 68 }, 69 ], 70 }; 71 72 testAccessibleTree(gRootAcc, accTree); 73 // After timeout after event hide for iframe was handled the document 74 // accessible for iframe's document should no longer be in cache. 75 ok(!isAccessibleInCache(gIframeDoc), 76 "The document accessible for iframe is in cache still after iframe hide!"); 77 ok(isAccessibleInCache(gDialogDoc), 78 `The document accessible for '${aURL}' is not in cache!`); 79 }; 80 81 this.getID = () => `open dialog '${aURL}'`; 82 } 83 84 function closeWndShutdownDoc() { 85 this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getAccessible(document)) ]; 86 87 this.invoke = () => { 88 gDialog.close(); 89 window.focus(); 90 }; 91 92 this.finalCheck = () => { 93 ok(!isAccessibleInCache(gDialogDoc), 94 "The document accessible for dialog is in cache still!"); 95 // After the window is closed all alive subdocument accessibles should 96 // be shut down. 97 ok(!isAccessibleInCache(gIframeDoc), 98 "The document accessible for iframe is in cache still!"); 99 100 gDialog = gDialogDoc = gRootAcc = gIframeDoc = null; 101 }; 102 103 this.getID = () => "close dialog"; 104 } 105 106 // ////////////////////////////////////////////////////////////////////////// 107 // Do tests 108 109 function doTests() { 110 if (Services.appShell.hasHiddenWindow) { 111 // Front end stuff sometimes likes to stuff things in the hidden window(s) 112 // in which case we should repress all accessibles for those. 113 114 // Try to create an accessible for the hidden window's document. 115 let doc = Services.appShell.hiddenDOMWindow.document; 116 let hiddenDocAcc = gAccService.getAccessibleFor(doc); 117 ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible."); 118 } 119 120 const gQueue = new eventQueue(); 121 gQueue.push(new openWndShutdownDoc("../../events/docload/docload_wnd.html")); 122 gQueue.push(new closeWndShutdownDoc()); 123 gQueue.invoke(); // Will call SimpleTest.finish(); 124 } 125 126 SimpleTest.waitForExplicitFinish(); 127 addA11yLoadEvent(doTests); 128 </script> 129 </head> 130 131 <body> 132 133 <a target="_blank" 134 href="https://bugzilla.mozilla.org/show_bug.cgi?id=571459" 135 title="Shutdown document accessible when presshell goes away"> 136 Mozilla Bug 571459 137 </a> 138 139 <p id="display"></p> 140 <div id="content" style="display: none"></div> 141 <pre id="test"> 142 </pre> 143 </body> 144 </html>