summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/support/fedcm-iframe.html
blob: c57f54e1dade5d33bfea9f7f8610bc46f43f1e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!doctype html>
<script type="module">
import {default_request_options} from './fedcm-helper.sub.js';

// Loading fedcm-iframe.html in the test will make a FedCM call on load, and
// trigger a postMessage upon completion.
//
// message {
//   string result: "Pass" | "Fail"
//   string token: token.token
//   string errorType: error.name
// }

window.onload = async () => {
  try {
    const cred = await navigator.credentials.get(default_request_options());
    window.top.postMessage({result: "Pass", token: cred.token}, '*');
  } catch (error) {
    window.top.postMessage({result: "Fail", errorType: error.name}, '*');
  }
};

</script>