blob: 070e2370b4e1bd7c33858111d6645836326cb714 [file] [edit]
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Digital Credential API: All requests fail framework validation rejects with TypeError</title>
<script src="/js-test-resources/js-test.js"></script>
<body onload="runTests()"></body>
<script>
description("Tests that navigator.credentials.get() rejects with TypeError when all org-iso-mdoc requests fail framework validation.");
jsTestIsAsync = true;
async function runTests() {
if (document.visibilityState === "hidden") {
await new Promise((resolve) => {
document.onvisibilitychange = resolve;
testRunner.setPageVisibility("visible");
});
}
internals.withUserGesture(() => {
window.promise1 = navigator.credentials.get({
digital: {
requests: [
{
protocol: "org-iso-mdoc",
data: {
deviceRequest: "not-valid-cbor",
encryptionInfo: "also-not-valid",
},
},
{
protocol: "org-iso-mdoc",
data: {
deviceRequest: "AAAA",
encryptionInfo: "BBBB",
},
},
],
},
mediation: "required",
});
});
await shouldRejectWithErrorName('promise1', 'TypeError');
internals.withUserGesture(() => {
window.promise2 = navigator.credentials.get({
digital: {
requests: [
{
protocol: "org-iso-mdoc",
data: {
deviceRequest: "invalid",
encryptionInfo: "invalid",
},
},
],
},
mediation: "required",
});
});
await shouldRejectWithErrorName('promise2', 'TypeError');
finishJSTest();
}
</script>