summaryrefslogtreecommitdiffstats
path: root/dom/credentialmanagement/identity/tests/browser/browser_close_prompt_on_timeout.js
blob: a71747e842f968f3638ebdb917fd7932699efb29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* 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_close_prompt_on_timeout() {
  await SpecialPowers.pushPrefEnv({
    set: [
      [
        "dom.security.credentialmanagement.identity.reject_delay.duration_ms",
        1000,
      ],
    ],
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);

  let requestCredential = async function () {
    let promise = content.navigator.credentials.get({
      identity: {
        providers: [
          {
            configURL:
              "https://example.net/tests/dom/credentialmanagement/identity/tests/browser/server_manifest.json",
            clientId: "browser",
            nonce: "nonce",
          },
        ],
      },
    });
    try {
      return await promise;
    } catch (err) {
      return err;
    }
  };

  let popupShown = BrowserTestUtils.waitForEvent(
    PopupNotifications.panel,
    "popupshown"
  );

  let request = ContentTask.spawn(tab.linkedBrowser, null, requestCredential);

  await popupShown;
  await request;

  let notification = PopupNotifications.getNotification(
    "identity-credential",
    tab.linkedBrowser
  );
  ok(
    !notification,
    "Identity Credential notification must not be present after timeout."
  );

  // Close tabs.
  await BrowserTestUtils.removeTab(tab);
  await SpecialPowers.popPrefEnv();
});