browser_single_concurrent_identity_request.js (1527B)
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_concurrent_identity_credential() { 10 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); 11 12 let requestCredential = async function () { 13 content.document.notifyUserGestureActivation(); 14 let promise = content.navigator.credentials.get({ 15 identity: { 16 mode: "active", 17 providers: [ 18 { 19 configURL: 20 "https://example.net/browser/dom/credentialmanagement/identity/tests/browser/server_manifest.json", 21 clientId: "browser", 22 nonce: "nonce", 23 }, 24 ], 25 }, 26 }); 27 try { 28 return await promise; 29 } catch (err) { 30 return err; 31 } 32 }; 33 34 ContentTask.spawn(tab.linkedBrowser, null, requestCredential); 35 36 let secondRequest = ContentTask.spawn( 37 tab.linkedBrowser, 38 null, 39 requestCredential 40 ); 41 42 let concurrentResponse = await secondRequest; 43 ok(concurrentResponse, "expect a result from the second request."); 44 ok(concurrentResponse.name, "expect a DOMException which must have a name."); 45 is( 46 concurrentResponse.name, 47 "NotAllowedError", 48 "Expected 'NotAllowedError', but got '" + concurrentResponse.name + "'" 49 ); 50 51 // Close tabs. 52 await BrowserTestUtils.removeTab(tab); 53 });