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

Cred Man: Add fully active checks #46422

Merged
merged 2 commits into from
May 29, 2024
Merged
Changes from 1 commit
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
55 changes: 55 additions & 0 deletions credential-management/non-fully-active.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Credential Management API 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></body>
<script>
promise_test(async (t) => {
// Create the iframe, wait for it to load...
const iframe = document.createElement("iframe");

// ...wait for the iframe to load...
await new Promise((resolve) => {
iframe.addEventListener("load", resolve, { once: true });
iframe.src = "resources/iframe.html";
document.body.appendChild(iframe);
});

// Steal credentials container.
const { credentials } = iframe.contentWindow.navigator;

marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
// No longer fully active.
iframe.remove();

// Try to get credentials while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
credentials.get({ password: true }),
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
"Expected NotAllowedError for get() on non-fully-active document"
);

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

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