test_browserui.xhtml (3176B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 4 type="text/css"?> 5 6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 7 title="Accessibility Name Calculating Test."> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 10 11 <script type="application/javascript" 12 src="../common.js"></script> 13 <script type="application/javascript" 14 src="../promisified-events.js"></script> 15 16 <script type="application/javascript"> 17 <![CDATA[ 18 const { BrowserTestUtils } = ChromeUtils.importESModule( 19 "resource://testing-common/BrowserTestUtils.sys.mjs"); 20 const ABOUT_MOZILLA_URL = "about:mozilla"; 21 const ABOUT_LICENSE_URL = "about:license"; 22 23 SimpleTest.waitForExplicitFinish(); 24 25 (async () => { 26 info("Opening a new browser window."); 27 const win = await BrowserTestUtils.openNewBrowserWindow({ 28 remote: false, 29 fission: false, 30 }); 31 const winFocused = SimpleTest.promiseFocus(win); 32 const loaded = BrowserTestUtils.browserLoaded( 33 win.gBrowser.selectedBrowser); 34 let docLoaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, event => 35 event.accessible.QueryInterface(nsIAccessibleDocument).URL === ABOUT_LICENSE_URL, 36 `Loaded tab: ${ABOUT_LICENSE_URL}`); 37 BrowserTestUtils.startLoadingURIString(win.gBrowser.selectedBrowser, 38 "about:license"); 39 await loaded; 40 await docLoaded; 41 await winFocused; 42 43 info(`Loading a new tab: ${ABOUT_MOZILLA_URL}.`); 44 docLoaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, event => 45 event.accessible.QueryInterface(nsIAccessibleDocument).URL === ABOUT_MOZILLA_URL, 46 `Added tab: ${ABOUT_MOZILLA_URL}`); 47 const tab = win.gBrowser.addTrustedTab(ABOUT_MOZILLA_URL); 48 await BrowserTestUtils.browserLoaded(tab.linkedBrowser); 49 await docLoaded; 50 51 info("Focusing on the newly opened tab."); 52 const focused = waitForEvent(EVENT_FOCUS, event => 53 event.DOMNode === win.gBrowser.getBrowserAtIndex(1).contentDocument); 54 await BrowserTestUtils.synthesizeKey("VK_TAB", { ctrlKey: true }, 55 win.gBrowser.selectedBrowser); 56 const focusEvent = await focused; 57 58 const title = getAccessible(win.document).name; 59 const accName = focusEvent.accessible.name; 60 isnot(title.indexOf(accName), -1, 61 `Window title contains the name of active tab document (Is "${accName}" in "${title}"?)`); 62 63 await BrowserTestUtils.closeWindow(win); 64 SimpleTest.finish(); 65 })(); 66 ]]> 67 </script> 68 69 <vbox flex="1" style="overflow: auto;"> 70 <body xmlns="http://www.w3.org/1999/xhtml"> 71 <a target="_blank" 72 href="https://bugzilla.mozilla.org/show_bug.cgi?id=507382" 73 title="focus is fired earlier than root accessible name is changed when switching between tabs"> 74 Mozilla Bug 75 </a> 76 <p id="display"></p> 77 <div id="content" style="display: none"> 78 </div> 79 <pre id="test"> 80 </pre> 81 </body> 82 83 <vbox id="eventdump"></vbox> 84 </vbox> 85 </window>