mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
Bug 1770232 [wpt PR 34130] - Add allow=federated-credentials permission policy, a=testonly
Automatic update from web-platform-tests Add allow=federated-credentials permission policy This CL introduces the 'federated-credentials' permission policy behind the IframeSupport feature parameter. BUG=1322320 Change-Id: I0023a93a47fa720be497d2caeda47211ccceb289 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3655073 Commit-Queue: Peter Kotwicz <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: Yi Gu <[email protected]> Reviewed-by: Ken Buchanan <[email protected]> Reviewed-by: Christian Biesinger <[email protected]> Reviewed-by: Nasko Oskov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1014013} -- wpt-commits: 500ed7b6db07ac94238c39fe33dd0557e0c61e1c wpt-pr: 34130
This commit is contained in:
1 parent
3041f6a092
commit
1434911220
3 files changed
+116
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<!doctype html>
|
||||
<link rel="help" href="https://wicg.github.io/FedCM">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<div id=log>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const host = get_host_info();
|
||||
const remoteBaseURL =
|
||||
host.HTTPS_REMOTE_ORIGIN +
|
||||
window.location.pathname.replace(/\/[^\/]*$/, '/');
|
||||
|
||||
async function createIframeAndWaitForMessage(test, iframeUrl, setPermissionPolicy) {
|
||||
const messageWatcher = new EventWatcher(test, window, "message");
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = iframeUrl;
|
||||
if (setPermissionPolicy) {
|
||||
iframe.allow = "federated-credentials";
|
||||
}
|
||||
document.body.appendChild(iframe);
|
||||
const message = await messageWatcher.wait_for("message");
|
||||
return message.data;
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
const message = await createIframeAndWaitForMessage(
|
||||
t, "support/fedcm-iframe.html",
|
||||
/*setPermissionPolicy=*/false);
|
||||
assert_equals(message.result, "Pass");
|
||||
assert_equals(message.token, "a_token");
|
||||
}, "FedCM enabled in same origin iframe");
|
||||
|
||||
promise_test(async t => {
|
||||
const message = await createIframeAndWaitForMessage(
|
||||
t, remoteBaseURL + "support/fedcm-iframe.html",
|
||||
/*setPermissionPolicy=*/true);
|
||||
assert_equals(message.result, "Pass");
|
||||
assert_equals(message.token, "a_token");
|
||||
}, "FedCM enabled in cross origin iframe with permissions policy");
|
||||
|
||||
promise_test(async t => {
|
||||
const message = await createIframeAndWaitForMessage(
|
||||
t, remoteBaseURL + "support/fedcm-iframe.html",
|
||||
/*setPermissionPolicy=*/false);
|
||||
assert_equals(message.result, "Fail");
|
||||
assert_equals(message.errorType, "NotAllowedError");
|
||||
}, "FedCM disabled in cross origin iframe without permissions policy");
|
||||
|
||||
promise_test(async t => {
|
||||
const message = await createIframeAndWaitForMessage(
|
||||
t, remoteBaseURL + "support/fedcm-iframe-level2.html",
|
||||
/*setPermissionPolicy=*/true);
|
||||
assert_equals(message.result, "Fail");
|
||||
assert_equals(message.errorType, "NotAllowedError");
|
||||
}, "FedCM disabled in nested cross origin iframes regardless of permissions policy");
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<link rel="help" href="https://wicg.github.io/FedCM">
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<div id=log>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const host = get_host_info();
|
||||
const remoteBaseURL =
|
||||
host.AUTHENTICATED_ORIGIN +
|
||||
window.location.pathname.replace(/\/[^\/]*$/, '/');
|
||||
|
||||
window.onload = async () => {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = remoteBaseURL + "fedcm-iframe.html";
|
||||
iframe.allow = "federated-credentials";
|
||||
document.body.appendChild(iframe);
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,38 @@
|
||||
<!doctype html>
|
||||
<script type="module">
|
||||
import {MockFederatedAuthRequest} from './fedcm-mock.js';
|
||||
|
||||
const test_options = {
|
||||
federated: {
|
||||
providers: [{
|
||||
url: 'https://idp.test',
|
||||
clientId: '1',
|
||||
}]
|
||||
}
|
||||
};
|
||||
const login_options = {
|
||||
nonce: '2',
|
||||
};
|
||||
|
||||
// Loading fedcm-iframe.html in the test will make a FedCM call on load, and
|
||||
// trigger a postMessage upon completion.
|
||||
//
|
||||
// message {
|
||||
// string result: "Pass" | "Fail"
|
||||
// string token: token.idToken
|
||||
// string errorType: error.name
|
||||
// }
|
||||
|
||||
window.onload = async () => {
|
||||
try {
|
||||
const mock = new MockFederatedAuthRequest();
|
||||
mock.returnIdToken("a_token");
|
||||
const cred = await navigator.credentials.get(test_options);
|
||||
const token = await cred.login(login_options);
|
||||
window.top.postMessage({result: "Pass", token: token.idToken}, '*');
|
||||
} catch (error) {
|
||||
window.top.postMessage({result: "Fail", errorType: error.name}, '*');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in new issue
Block a user