summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/fedcm-pending-userinfo.https.html
blob: 0ecae3e80a4bb9f3fbe27ff32284a5f503a099b1 (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
<!DOCTYPE html>
<title>Federated Credential Management API pending getUserInfo() test.</title>
<link rel="help" href="https://fedidcg.github.io/FedCM">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<body>

<script type="module">
import {alt_manifest_origin,
        alt_request_options_with_mediation_required,
        fedcm_test,
        fedcm_get_and_select_first_account} from './support/fedcm-helper.sub.js';

async function createIframeWithPermissionPolicyAndWaitForMessage(test, iframeUrl) {
    const messageWatcher = new EventWatcher(test, window, "message");
    let iframe = document.createElement("iframe");
    iframe.src = iframeUrl;
    iframe.allow = "identity-credentials-get";
    document.body.appendChild(iframe);
    const message = await messageWatcher.wait_for("message");
    return message.data;
}

fedcm_test(async t => {
  const cred = await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
  assert_equals(cred.token, "token");

  const iframe_in_idp_scope = `${alt_manifest_origin}/\
credential-management/support/fedcm/pending-userinfo-iframe.html`;
  const message = await createIframeWithPermissionPolicyAndWaitForMessage(t, iframe_in_idp_scope);
  assert_equals(message, "Pass");
}, 'Test basic User InFo API flow');
</script>