browser_UITour_private_browsing.js (1841B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests that UITour will work in private browsing windows with 8 * tabs pointed at sites that have the uitour permission set to 9 * allowed. 10 */ 11 add_task(async function test_privatebrowsing_window() { 12 // These two constants point to origins that have a default 13 // uitour allow entry in browser/app/permissions. The expectation is 14 // that these defaults are special, in that they'll apply for both 15 // private and non-private contexts. 16 const ABOUT_ORIGIN_WITH_UITOUR_DEFAULT = "about:newtab"; 17 const HTTPS_ORIGIN_WITH_UITOUR_DEFAULT = "https://www.mozilla.org"; 18 19 let { UITourUtils } = ChromeUtils.importESModule( 20 "moz-src:///browser/components/uitour/UITourUtils.sys.mjs" 21 ); 22 23 let win = await BrowserTestUtils.openNewBrowserWindow({ private: true }); 24 let browser = win.gBrowser.selectedBrowser; 25 26 for (let uri of [ 27 ABOUT_ORIGIN_WITH_UITOUR_DEFAULT, 28 HTTPS_ORIGIN_WITH_UITOUR_DEFAULT, 29 ]) { 30 BrowserTestUtils.startLoadingURIString(browser, uri); 31 await BrowserTestUtils.browserLoaded(browser); 32 33 Assert.ok( 34 UITourUtils.ensureTrustedOrigin( 35 browser.browsingContext.currentWindowGlobal 36 ), 37 "Page should be considered trusted for UITour in the parent." 38 ); 39 40 await SpecialPowers.spawn(browser, [], async () => { 41 let actor = content.windowGlobalChild.getActor("UITour"); 42 // eslint-disable-next-line no-shadow 43 let { UITourUtils } = ChromeUtils.importESModule( 44 "moz-src:///browser/components/uitour/UITourUtils.sys.mjs" 45 ); 46 Assert.ok( 47 UITourUtils.ensureTrustedOrigin(actor.manager), 48 "Page should be considered trusted for UITour." 49 ); 50 }); 51 } 52 await BrowserTestUtils.closeWindow(win); 53 });