Bug 1501941 [wpt PR 13717] - Correct inherited feature policy when allow attribute is used., a=testonly

Automatic update from web-platform-testsCorrect inherited feature policy when allow attribute is used.

This fixes an error in the inherited policy calculation where a frame
which was explicitly allowed to use a feature through the Feature-Policy
header would be blocked if the "allow" attribute was also present on
the iframe element.

The behaviour now matches the spec algorithm at
https://wicg.github.io/feature-policy/#define-inherited-policy-in-container

Tests have been added to catch this case.

Change-Id: I7a394202c615be3088fda738d7fc65f16bcadf34
Reviewed-on: https://chromium-review.googlesource.com/c/1293610
Reviewed-by: Luna Lu <loonybear@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605431}

--

wpt-commits: d5f4dec283def0baeca6e5a88223dac67935e798
wpt-pr: 13717
This commit is contained in:
Ian Clelland 2018-11-13 11:52:23 +00:00 коммит произвёл moz-wptsync-bot
Родитель c08a7096a5
Коммит bcd7940b4f
2 изменённых файлов: 66 добавлений и 0 удалений

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

@ -0,0 +1,65 @@
<!DOCTYPE html>
<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/feature-policy/resources/featurepolicy.js></script>
<!-- Feature-Policy: fullscreen cross_origin https://www.example.com; -->
<script>
'use strict';
var same_origin = 'https://{{domains[]}}:{{ports[https][0]}}';
var cross_origin = 'https://{{domains[www]}}:{{ports[https][0]}}';
var same_origin_src = '/feature-policy/resources/feature-policy-allowedfeatures.html';
var cross_origin_src = cross_origin + same_origin_src;
var header_policy = 'Feature-Policy: fullscreen \'self\' ' + cross_origin +
' https://www.example.com;';
// Test that fullscreen's allowlist is [same_origin, cross_origin, 'https://www.example.com']
test(function() {
assert_array_equals(
document.policy.getAllowlistForFeature('fullscreen'),
[cross_origin, 'https://www.example.com']);
}, header_policy + ' -- test allowlist is [cross_origin, https://www.example.com]');
// Test that fullscreen is disallowed on same_origin, allowed on some cross_origin subframes.
test_disallowed_feature_for_subframe(
header_policy + ' -- test fullscreen is allowed on same-origin subframe',
'fullscreen',
same_origin_src);
test_allowed_feature_for_subframe(
header_policy + ' -- test fullscreen is allowed on cross-origin ' + cross_origin_src + ' subframe',
'fullscreen',
cross_origin_src);
var cross_origin_src1 = 'https://{{domains[www1]}}:{{ports[https][0]}}' + same_origin_src;
test_disallowed_feature_for_subframe(
header_policy + ' -- test fullscreen is disallowed on cross-origin ' + cross_origin_src1 + ' subframe',
'fullscreen',
cross_origin_src1);
// dynamically update sub frame's container policy
var disallow = "fullscreen 'none';"
test_disallowed_feature_for_subframe(
header_policy + ', iframe.allow = ' + disallow + ' -- test fullscreen is disallowed on same-origin subframe',
'fullscreen',
same_origin_src,
disallow);
test_disallowed_feature_for_subframe(
header_policy + 'iframe.allow = ' + disallow + ' -- test fullscreen is allowed on specific cross-origin subframe',
'fullscreen',
cross_origin_src,
disallow);
var allow = "fullscreen " + cross_origin;
test_disallowed_feature_for_subframe(
header_policy + ', iframe.allow = ' + allow + ' -- test fullscreen is disallowed on same-origin subframe',
'fullscreen',
same_origin_src,
allow);
test_allowed_feature_for_subframe(
header_policy + 'iframe.allow = ' + allow + ' -- test fullscreen is allowed on specific cross-origin subframe',
'fullscreen',
cross_origin_src,
allow);
</script>
</body>

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

@ -0,0 +1 @@
Feature-Policy: fullscreen https://{{domains[www]}}:{{ports[https][0]}} https://www.example.com;