1
0
Fork 0
firefox/testing/web-platform/tests/digital-credentials/user-activation.https.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

70 lines
2.5 KiB
HTML

<!DOCTYPE html>
<title>Digital Credential API: get() consumes user activation.</title>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.js" type="module"></script>
<body></body>
<script type="module">
import { makeGetOptions, makeCreateOptions } from "./support/helper.js";
promise_test(async (t) => {
assert_false(
navigator.userActivation.isActive,
"User activation should not be active"
);
const options = makeGetOptions("openid4vp");
await promise_rejects_dom(
t,
"NotAllowedError",
navigator.credentials.get(options)
);
}, "navigator.credentials.get() calling the API without user activation should reject with NotAllowedError.");
promise_test(async (t) => {
await test_driver.bless();
const abort = new AbortController();
const options = makeGetOptions("openid4vp");
options.signal = abort.signal;
assert_true(
navigator.userActivation.isActive,
"User activation should be active after test_driver.bless()."
);
const getPromise = navigator.credentials.get(options);
abort.abort();
await promise_rejects_dom(t, "AbortError", getPromise);
assert_false(
navigator.userActivation.isActive,
"User activation should be consumed after navigator.credentials.get()."
);
}, "navigator.credentials.get() consumes user activation.");
promise_test(async (t) => {
assert_false(
navigator.userActivation.isActive,
"User activation should not be active"
);
const options = makeCreateOptions([]);
await promise_rejects_dom(
t,
"NotAllowedError",
navigator.credentials.create(options)
);
}, "navigator.credentials.create() calling the API without user activation should reject with NotAllowedError.");
promise_test(async (t) => {
await test_driver.bless();
assert_true(
navigator.userActivation.isActive,
"User activation should be active after test_driver.bless()."
);
const options = makeCreateOptions([]);
await promise_rejects_js(t, TypeError, navigator.credentials.create(options));
assert_false(
navigator.userActivation.isActive,
"User activation should be consumed after navigator.credentials.create()."
);
}, "navigator.credentials.create() consumes user activation.");
</script>