browser_close_prompt_on_timeout.js (1657B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const TEST_URL = "https://example.com/"; 8 9 add_task(async function test_close_prompt_on_timeout() { 10 await SpecialPowers.pushPrefEnv({ 11 set: [ 12 [ 13 "dom.security.credentialmanagement.identity.reject_delay.duration_ms", 14 500, 15 ], 16 ], 17 }); 18 19 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); 20 21 let requestCredential = async function () { 22 content.document.notifyUserGestureActivation(); 23 let promise = content.navigator.credentials.get({ 24 identity: { 25 mode: "active", 26 providers: [ 27 { 28 configURL: 29 "https://example.net/browser/dom/credentialmanagement/identity/tests/browser/server_manifest.json", 30 clientId: "browser", 31 nonce: "nonce", 32 }, 33 ], 34 }, 35 }); 36 try { 37 return await promise; 38 } catch (err) { 39 return err; 40 } 41 }; 42 43 let popupShown = BrowserTestUtils.waitForEvent( 44 PopupNotifications.panel, 45 "popupshown" 46 ); 47 48 let request = ContentTask.spawn(tab.linkedBrowser, null, requestCredential); 49 50 await popupShown; 51 await request; 52 53 let notification = PopupNotifications.getNotification( 54 "identity-credential", 55 tab.linkedBrowser 56 ); 57 ok( 58 !notification, 59 "Identity Credential notification must not be present after timeout." 60 ); 61 62 // Close tabs. 63 await BrowserTestUtils.removeTab(tab); 64 await SpecialPowers.popPrefEnv(); 65 });