/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const TEST_URL = "https://example.com/"; add_task(async function test_concurrent_identity_credential() { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); let requestCredential = async function () { content.document.notifyUserGestureActivation(); let promise = content.navigator.credentials.get({ identity: { mode: "active", providers: [ { configURL: "https://example.net/browser/dom/credentialmanagement/identity/tests/browser/server_manifest.json", clientId: "browser", nonce: "nonce", }, ], }, }); try { return await promise; } catch (err) { return err; } }; SpecialPowers.spawn(tab.linkedBrowser, [], requestCredential).catch(() => {}); let secondRequest = SpecialPowers.spawn( tab.linkedBrowser, [], requestCredential ); let concurrentResponse = await secondRequest; ok(concurrentResponse, "expect a result from the second request."); ok(concurrentResponse.name, "expect a DOMException which must have a name."); is( concurrentResponse.name, "NotAllowedError", "Expected 'NotAllowedError', but got '" + concurrentResponse.name + "'" ); // Close tabs. await BrowserTestUtils.removeTab(tab); });