blob: 37fe6e1cd891b3f1c4500a0c09b0f6d2c603bccf [file] [log] [blame]
<!doctype html>
<script src="./otpcredential-helper.js"></script>
<script>
'use strict';
// Loading otpcredential-iframe.html in the test will make an OTPCredentials
// call on load, and trigger a postMessage upon completion.
//
// message {
// string result: "Pass" | "Fail"
// string code: credentials.code
// string errorType: error.name
// }
// Intercept successful calls and return mocked value.
(async function() {
await expect(receive).andReturn(() => {
return Promise.resolve({
status: Status.kSuccess,
otp: "ABC123",
});
});
}());
window.onload = async () => {
try {
const credentials =
await navigator.credentials.get({otp: {transport: ["sms"]}});
window.parent.postMessage({result: "Pass", code: credentials.code}, '*');
} catch (error) {
window.parent.postMessage({result: "Fail", errorType: error.name}, '*');
}
}
</script>