mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
fd69932b4e
Automatic update from web-platform-testsupdate wpt feature policy tests, making them long tests Bug: 829921 Change-Id: Ia2c70c62d4a4235b21996bbd185746080e1efa35 Reviewed-on: https://chromium-review.googlesource.com/c/1320010 Reviewed-by: Robert Ma <robertma@chromium.org> Commit-Queue: Luna Lu <loonybear@chromium.org> Cr-Commit-Position: refs/heads/master@{#606045} -- wpt-commits: 1a7cb3deb6c8661e4cf245a7ffc3e324fb6795f2 wpt-pr: 13954
185 lines
9.0 KiB
HTML
185 lines
9.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta name="timeout" content="long">
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
</head>
|
|
<body>
|
|
<script src=/feature-policy/resources/featurepolicy.js></script>
|
|
<!-- Feature-Policy: fullscreen 'self'; -->
|
|
<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 data_src = 'data:text/html,<h1>data: URL</h1>';
|
|
var policies = [
|
|
{allow: "*", sameOriginTestExpect: true, crossOriginTestExpect: true, dataOriginTestExpect: false},
|
|
{allow: "'self'", sameOriginTestExpect: true, crossOriginTestExpect: false, dataOriginTestExpect: false},
|
|
{allow: "'none'", sameOriginTestExpect: false, crossOriginTestExpect: false, dataOriginTestExpect: false},
|
|
{allow: "'self' " + cross_origin + " https://www.example.com", sameOriginTestExpect: true, crossOriginTestExpect: true, dataOriginTestExpect: false}];
|
|
var pipe_front = '?pipe=sub|header(Feature-Policy,fullscreen ';
|
|
var pipe_end = ';)';
|
|
var header_policies = ["*", "'self'", "'none'"];
|
|
|
|
// Test that frame.policy inherits from parent's header policy when allow
|
|
// attribute is not specified.
|
|
test(function() {
|
|
test_frame_policy('fullscreen', same_origin_src, undefined, true);
|
|
}, 'Test frame policy on same origin iframe inherit from header policy.');
|
|
test(function() {
|
|
test_frame_policy('fullscreen', cross_origin_src, undefined, false);
|
|
}, 'Test frame policy on cross origin iframe inherit from header policy.');
|
|
test(function() {
|
|
test_frame_policy('fullscreen', undefined, true, true);
|
|
}, 'Test frame policy on srcdoc iframe inherit from header policy.');
|
|
test(function() {
|
|
test_frame_policy('fullscreen', same_origin_src, true, true);
|
|
}, 'Test frame policy on srcdoc + same origin iframe inherit from header policy.');
|
|
test(function() {
|
|
test_frame_policy('fullscreen', cross_origin_src, true, true);
|
|
}, 'Test frame policy on srcdoc + cross origin iframe inherit from header policy.');
|
|
test(function() {
|
|
test_frame_policy('fullscreen', data_src, undefined, false);
|
|
}, 'Test frame policy on data: URL 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, undefined, false, undefined, false, true);
|
|
}, 'Test frame policy on sandboxed iframe with no allow attribute.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, undefined, true, 'fullscreen', false, true);
|
|
}, 'Test frame policy on sandboxed iframe with allow="fullscreen".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, undefined, true, 'fullscreen \'src\'', false, true);
|
|
}, 'Test frame policy on sandboxed iframe with allow="fullscreen \'src\'".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, undefined, false, 'fullscreen ' + cross_origin, false, true);
|
|
}, 'Test frame policy on sandboxed iframe with allow="fullscreen ' + cross_origin + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', undefined, true, true, 'fullscreen', false, true);
|
|
}, 'Test frame policy on srcdoc sandboxed iframe with allow="fullscreen".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, true, true, 'fullscreen', false, true);
|
|
}, 'Test frame policy on srcdoc + same origin sandboxed iframe with allow="fullscreen".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, true, true, 'fullscreen', false, true);
|
|
}, 'Test frame policy on srcdoc + cross origin sandboxed iframe with allow="fullscreen".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', data_src, undefined, false, 'fullscreen ' + cross_origin, false, true);
|
|
}, 'Test frame policy on sandboxed srcdoc 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() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, undefined,
|
|
policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on same origin iframe with allow = "' + policies[i].allow + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, undefined,
|
|
policies[i].crossOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', undefined, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on srcdoc iframe with allow = "' + policies[i].allow + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on srcdoc + same origin iframe with allow = "' + policies[i].allow + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on srcdoc + cross origin iframe with allow = "' + policies[i].allow + '".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', data_src, undefined, policies[i].dataOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on data: URL origin iframe with allow = "' + policies[i].allow + '".');
|
|
}
|
|
|
|
// Test that the header policy of the iframe document does not change the
|
|
// frame policy.
|
|
for (var i = 0; i < policies.length; i++) {
|
|
for (var j = 0; j < header_policies.length; j++) {
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen',
|
|
same_origin_src + pipe_front + header_policies[j] + pipe_end,
|
|
undefined, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on same origin iframe with allow = "' + policies[i].allow +
|
|
'" and header policy = "Feature-Policy: fullscreen ' + header_policies[j] + ';".');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen',
|
|
cross_origin_src + pipe_front + header_policies[j] + pipe_end,
|
|
undefined, policies[i].crossOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';');
|
|
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow +
|
|
'" and header policy = "Feature-Policy: fullscreen ' + header_policies[j] + ';".');
|
|
}
|
|
}
|
|
|
|
// Test that the allow attribute overrides allowfullscreen.
|
|
for (var i = 0; i < policies.length; i++) {
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, undefined,
|
|
policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on same origin iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, undefined,
|
|
policies[i].crossOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', undefined, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on srcdoc iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', same_origin_src, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on srcdoc + same origin iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', cross_origin_src, true, policies[i].sameOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on srcdoc + cross origin iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
test(function() {
|
|
test_frame_policy(
|
|
'fullscreen', data_src, undefined, policies[i].dataOriginTestExpect,
|
|
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
|
|
}, 'Test frame policy on data: URL origin iframe with allow = "' + policies[i].allow +
|
|
'" and allowfullscreen.');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|