browser_switchTabPermissionPrompt.js (1401B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function test_check_file_prompt() { 7 let initialTab = gBrowser.selectedTab; 8 await BrowserTestUtils.withNewTab("about:blank", async browser => { 9 await BrowserTestUtils.switchTab(gBrowser, initialTab); 10 11 let testHelper = async function (uri, expectedValue) { 12 BrowserTestUtils.startLoadingURIString(browser, uri); 13 await BrowserTestUtils.browserLoaded(browser, false, uri); 14 let dialogFinishedShowing = TestUtils.topicObserved( 15 "common-dialog-loaded" 16 ); 17 await SpecialPowers.spawn(browser, [], () => { 18 content.setTimeout(() => { 19 content.alert("Hello"); 20 }, 0); 21 }); 22 23 let [dialogWin] = await dialogFinishedShowing; 24 let checkbox = dialogWin.document.getElementById("checkbox"); 25 info("Got: " + checkbox.label); 26 ok( 27 checkbox.label.includes(expectedValue), 28 `Checkbox label should mention domain (${expectedValue}).` 29 ); 30 31 dialogWin.document.querySelector("dialog").acceptDialog(); 32 }; 33 34 await testHelper("https://example.com/1", "example.com"); 35 await testHelper("about:robots", "about:"); 36 let file = Services.io.newFileURI( 37 Services.dirsvc.get("Desk", Ci.nsIFile) 38 ).spec; 39 await testHelper(file, "file://"); 40 }); 41 });