Bug 1446406 [wpt PR 10076] - Allow feature policy to be used in opaque origins., a=testonly

Automatic update from web-platform-testsAllow feature policy to be used in opaque origins.

Currently, policy-controlled features do not work as expected in
frames with opaque origins, such as isolated sandboxes and data: URLs,
because the eventual opaque origin of the frame is not known when the
HTMLFrameOwnerElement builds the container policy, and so has no way
to tell the browser that a particular origin should be allowed.

This CL adds a new member to the ParsedFeaturePolicyDeclaration, which
indicates that the iframe policy is expected to apply to the origin of
the frame, and is used when that frame has an opaque origin. This can
be triggered with an iframe of the form

<iframe sandbox allow="feature">

or

<iframe sandbox allow="feature src">

This flag is checked when building the feature policy in the new frame,
and ensures that the new feature policy will allow the feature in that
origin.

This is the first part of the eventual solution -- currently this has
the effect of allowing the feature even if a sandboxed frame navigates
to a new page (causing a new opaque origin to be created for it).
Subsequent CLs will add a unique identified to each such origin, and
ensure that the generated policies are properly tied to the specific
origin of the frame.

Bug: 690520
Change-Id: Ie18b9bc3c36be6550baf5a03e355871b9589fd40
Reviewed-on: https://chromium-review.googlesource.com/963382
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550463}

--

wpt-commits: 4c8580c189ce4501997af80b599bea070b1a7299
wpt-pr: 10076
This commit is contained in:
Ian Clelland 2018-04-22 15:02:01 +00:00 коммит произвёл moz-wptsync-bot
Родитель 69e7030354
Коммит b11c313f43
3 изменённых файлов: 26 добавлений и 3 удалений

Просмотреть файл

@ -554949,7 +554949,7 @@
"support"
],
"feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html": [
"7a68af16b8cb8292185997cefdfeb3be295813a7",
"fdc37b6a3d16b35095a05b2857faeaf3d28c1feb",
"testharness"
],
"feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html.sub.headers": [
@ -555129,7 +555129,7 @@
"support"
],
"feature-policy/resources/featurepolicy.js": [
"87607362a81716400d9fee10958893e7a785f74e",
"a95ee6fc23217f5fc271763f5363a09b0ff04537",
"support"
],
"feature-policy/resources/picture-in-picture.js": [

Просмотреть файл

@ -28,6 +28,24 @@
test_frame_policy('fullscreen', cross_origin_src, false);
}, 'Test frame policy on cross origin iframe inherit from header policy.');
// Test that frame policy can be used for sandboxed frames
test(function() {
test_frame_policy(
'fullscreen', same_origin_src, false, undefined, false, true);
}, 'Test frame policy on sandboxed iframe with no allow attribute.');
test(function() {
test_frame_policy(
'fullscreen', same_origin_src, true, 'fullscreen', false, true);
}, 'Test frame policy on sandboxed iframe with allow="fullscreen".');
test(function() {
test_frame_policy(
'fullscreen', same_origin_src, true, 'fullscreen \'src\'', false, true);
}, 'Test frame policy on sandboxed iframe with allow="fullscreen \'src\'".');
test(function() {
test_frame_policy(
'fullscreen', cross_origin_src, false, 'fullscreen ' + cross_origin, false, true);
}, 'Test frame policy on sandboxed iframe with allow="fullscreen ' + cross_origin + '".');
// Test frame policy with allow attribute set to be one of the policies above.
for (var i = 0; i < policies.length; i++) {
test(function() {

Просмотреть файл

@ -393,8 +393,10 @@ function test_subframe_header_policy(
// test_expect: boolean value of whether the feature should be allowed.
// allow: optional, the allow attribute (container policy) of the iframe.
// allowfullscreen: optional, boolean value of allowfullscreen attribute.
// sandbox: optional boolean. If true, the frame will be sandboxed (with
// allow-scripts, so that tests can run in it.)
function test_frame_policy(
feature, src, test_expect, allow, allowfullscreen) {
feature, src, test_expect, allow, allowfullscreen, sandbox) {
let frame = document.createElement('iframe');
document.body.appendChild(frame);
// frame_policy should be dynamically updated as allow and allowfullscreen is
@ -406,6 +408,9 @@ function test_frame_policy(
if (!!allowfullscreen) {
frame.setAttribute('allowfullscreen', true);
}
if (!!sandbox) {
frame.setAttribute('sandbox', 'allow-scripts');
}
frame.src = src;
if (test_expect) {
assert_true(frame_policy.allowedFeatures().includes(feature));