browser_permission_doorhanger.js (2125B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that permission popups asking for user approval still appear in RDM 7 const DUMMY_URL = "http://example.com/"; 8 const TEST_URL = `${URL_ROOT}geolocation.html`; 9 const TEST_SURL = TEST_URL.replace("http://example.com", "https://example.com"); 10 11 function waitForGeolocationPrompt(win, browser) { 12 return new Promise(resolve => { 13 win.PopupNotifications.panel.addEventListener( 14 "popupshown", 15 function popupShown() { 16 const notification = win.PopupNotifications.getNotification( 17 "geolocation", 18 browser 19 ); 20 if (notification) { 21 win.PopupNotifications.panel.removeEventListener( 22 "popupshown", 23 popupShown 24 ); 25 resolve(); 26 } 27 } 28 ); 29 }); 30 } 31 32 addRDMTask( 33 null, 34 async function () { 35 // we want to explicitly tests http and https, hence 36 // disabling https-first mode for this test. 37 await pushPref("dom.security.https_first", false); 38 39 const tab = await addTab(DUMMY_URL); 40 const browser = tab.linkedBrowser; 41 const win = browser.ownerGlobal; 42 43 let waitPromptPromise = waitForGeolocationPrompt(win, browser); 44 45 // Checks if a geolocation permission doorhanger appears when openning a page 46 // requesting geolocation 47 await navigateTo(TEST_SURL); 48 await waitPromptPromise; 49 50 ok(true, "Permission doorhanger appeared without RDM enabled"); 51 52 // Lets switch back to the dummy website and enable RDM 53 await navigateTo(DUMMY_URL); 54 const { ui } = await openRDM(tab); 55 await waitForDeviceAndViewportState(ui); 56 57 const newBrowser = ui.getViewportBrowser(); 58 waitPromptPromise = waitForGeolocationPrompt(win, newBrowser); 59 60 // Checks if the doorhanger appeared again when reloading the geolocation 61 // page inside RDM 62 await navigateTo(TEST_SURL); 63 64 await waitPromptPromise; 65 66 ok(true, "Permission doorhanger appeared inside RDM"); 67 68 await closeRDM(tab); 69 await removeTab(tab); 70 }, 71 { onlyPrefAndTask: true } 72 );