fune/testing/web-platform/tests/permissions-policy/permissions-policy-javascript-url-frame-policy.https.html
Charlie Hu 5400cad965 Bug 1682356 [wpt PR 26891] - [Frame Policy] Add test to verify frame policy works correctly in javascript url, a=testonly
Automatic update from web-platform-tests
[Frame Policy] Add test to verify frame policy works correctly in javascript url

Previous fix(https://chromium-review.googlesource.com/c/chromium/src/+/2181318)
on uninitialized frame policy in javascript url
navigation does not include a test case because it is a security
fix.

Since the fix has landed in M84 which is stable right now, this CL
adds the test case for the fix.

Bug: 1074340
Change-Id: Ia10a972183b02cdac28a2f29cabb7f13caf168e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2297708
Commit-Queue: Charlie Hu <chenleihu@google.com>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837169}

--

wpt-commits: 67b62d48eea3e1c82356cfeda39deef6d2a96a08
wpt-pr: 26891
2020-12-21 14:59:46 +00:00

40 lines
1 KiB
HTML

<!DOCTYPE html>
<head>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script>
'use strict';
const script = 'script';
const testPage = `
<${script}>
parent.postMessage(document.fullscreenEnabled, '*');
</${script}>
`;
function runTest(allow, expectation) {
return new Promise((resolve, reject) => {
window.onmessage = event => resolve(event.data);
const iframe = document.createElement("iframe");
iframe.allow = allow;
iframe.src = `javascript: \`${testPage}\``;
document.body.appendChild(iframe);
}).then(enabled => {
assert_equals(enabled, expectation);
});
}
promise_test(() => runTest('fullscreen *', true),
'allow attribute(container policy) can enable feature on javascript generated document');
promise_test(() => runTest("fullscreen 'none'", false),
'allow attribute(container policy) can disable feature on javascript generated document');
</script>
</body>