[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digital credentials: test api against non-fully active doc #46504

Merged
merged 2 commits into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions digital-credentials/non-fully-active.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Digital Credentials Test: non-fully active document</title>
<link
rel="help"
href="https://github.com/w3c/webappsec-credential-management"
/>
<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>
<iframe></iframe>
</body>
<script>
promise_setup(async () => {
const iframe = document.querySelector("iframe");
await new Promise((resolve) => {
iframe.addEventListener("load", resolve, { once: true });
iframe.src = "about:blank";
document.body.appendChild(iframe);
});
});

promise_test(async (t) => {
const iframe = document.querySelector("iframe");

// The signal check happens after the fully active check.
// This allows us to confirm the the right error is thrown
// and in the right order.
const controller = new iframe.contentWindow.AbortController();
const signal = controller.signal;
controller.abort();

// Steal all the needed references.
const { identity } = iframe.contentWindow.navigator;
const DOMExceptionCtor = iframe.contentWindow.DOMException;

// No longer fully active.
iframe.remove();

// Try to get credentials while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
DOMExceptionCtor,
identity.get({ signal }),
"Expected NotAllowedError for get() on non-fully-active document"
);

// Try to create credentials while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
DOMExceptionCtor,
identity.create({ signal }),
"Expected NotAllowedError for create() on non-fully-active document"
);

// Try to prevent silent access while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
DOMExceptionCtor,
identity.preventSilentAccess(),
"Expected NotAllowedError for preventSilentAccess() on non-fully-active document"
);
}, "non-fully active document behavior for CredentialsContainer");
</script>