browser_test_panel.js (1826B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* import-globals-from ../../mochitest/role.js */ 7 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 8 9 // Verify we receive hide and show notifications when the chrome 10 // XUL alert is closed or opened. Mac expects both notifications to 11 // properly communicate live region changes. 12 async function runTests(browser) { 13 ok(PopupNotifications, "PopupNotifications object exists"); 14 ok(PopupNotifications.panel, "PopupNotifications panel exists"); 15 16 // When available, the popup panel makes itself a child of the chrome window. 17 // To verify it isn't accessible without reproducing the entirety of the chrome 18 // window tree, we check instead that the panel is not accessible. 19 ok(!isAccessible(PopupNotifications.panel), "Popup panel is not accessible"); 20 21 const panelShown = waitForEvent(EVENT_SHOW, PopupNotifications.panel); 22 const notification = PopupNotifications.show( 23 browser, 24 "test-notification", 25 "hello world", 26 PopupNotifications.panel.id 27 ); 28 29 await panelShown; 30 31 ok(isAccessible(PopupNotifications.panel), "Popup panel is accessible"); 32 testAccessibleTree(PopupNotifications.panel, { 33 ALERT: [ 34 { LABEL: [{ TEXT_LEAF: [] }] }, 35 { PUSHBUTTON: [] }, 36 { PUSHBUTTON: [] }, 37 ], 38 }); 39 // Verify the popup panel is associated with the chrome window. 40 is( 41 PopupNotifications.panel.ownerGlobal, 42 getMainChromeWindow(window), 43 "Popup panel is associated with the chrome window" 44 ); 45 46 const panelHidden = waitForEvent(EVENT_HIDE, PopupNotifications.panel); 47 PopupNotifications.remove(notification); 48 49 await panelHidden; 50 51 ok(!isAccessible(PopupNotifications.panel), "Popup panel is not accessible"); 52 } 53 54 addAccessibleTask(``, runTests);