Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WPT tests for feature policy frame policy #8922

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!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 *; -->
<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 policies = [
{allow: "*", sameOriginTestExpect: true, crossOriginTestExpect: true},
{allow: "'self'", sameOriginTestExpect: true, crossOriginTestExpect: false},
{allow: "'none'", sameOriginTestExpect: false, crossOriginTestExpect: false},
{allow: "'self' " + cross_origin + " https://www.example.com", sameOriginTestExpect: true, crossOriginTestExpect: true}];
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, true);
}, 'Test frame policy on same origin iframe inherit from header policy.');
test(function() {
test_frame_policy('fullscreen', cross_origin_src, true);
}, 'Test frame policy on cross origin iframe inherit from header policy.');

// 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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';');
}, 'Test frame policy on cross 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,
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,
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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow +
'" and allowfullscreen.');
}
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature-Policy: fullscreen *;
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!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 '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 policies = [
{allow: "*", sameOriginTestExpect: true, crossOriginTestExpect: true},
{allow: "'self'", sameOriginTestExpect: true, crossOriginTestExpect: false},
{allow: "'none'", sameOriginTestExpect: false, crossOriginTestExpect: false},
{allow: "'self' " + cross_origin + " https://www.example.com", sameOriginTestExpect: true, crossOriginTestExpect: true}];
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, true);
}, 'Test frame policy on same origin iframe inherit from header policy.');
test(function() {
test_frame_policy('fullscreen', cross_origin_src, false);
}, 'Test frame policy on cross origin iframe inherit from header policy.');

// 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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';');
}, 'Test frame policy on cross 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,
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,
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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow +
'" and allowfullscreen.');
}
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature-Policy: fullscreen 'self';
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<!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 'self' 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 cross_origin1 = 'https://{{domains[www1]}}:{{ports[https][0]}}';
var same_origin_src = '/feature-policy/resources/feature-policy-allowedfeatures.html';
var cross_origin_src = cross_origin + same_origin_src;
var cross_origin_src1 = cross_origin1 + same_origin_src;
// Test feature policy with same_origin_src and cross_origin_src.
var policies = [
{allow: "*", sameOriginTestExpect: true, crossOriginTestExpect: true, crossOrigin1TestExpect: true},
{allow: "'self'", sameOriginTestExpect: true, crossOriginTestExpect: false, crossOrigin1TestExpect: false},
{allow: "'none'", sameOriginTestExpect: false, crossOriginTestExpect: false, crossOrigin1TestExpect: false},
{allow: "'self' " + cross_origin + " https://www.example.com", sameOriginTestExpect: true, crossOriginTestExpect: true, crossOrigin1TestExpect: 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, true);
}, 'Test frame policy on same origin iframe inherit from header policy.');
test(function() {
test_frame_policy('fullscreen', cross_origin_src, true);
}, 'Test frame policy on cross origin iframe inherit from header policy.');
test(function() {
test_frame_policy('fullscreen', cross_origin_src1, false);
}, 'Test frame policy on another cross origin iframe inherit from header policy.');

// 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, 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, 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', cross_origin_src1, policies[i].crossOrigin1TestExpect,
'fullscreen ' + policies[i].allow + ';');
}, 'Test frame policy on another cross 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,
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,
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(function() {
test_frame_policy(
'fullscreen',
cross_origin_src1 + pipe_front + header_policies[j] + pipe_end,
policies[i].crossOrigin1TestExpect,
'fullscreen ' + policies[i].allow + ';');
}, 'Test frame policy on another 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, 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, 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', cross_origin_src1, policies[i].crossOrigin1TestExpect,
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
}, 'Test frame policy on another cross origin iframe with allow = "' + policies[i].allow +
'" and allowfullscreen.');
}
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature-Policy: fullscreen 'self' https://{{domains[www]}}:{{ports[https][0]}} https://www.example.com;
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!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 'none'; -->
<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 policies = [
{allow: "*", sameOriginTestExpect: false, crossOriginTestExpect: false},
{allow: "'self'", sameOriginTestExpect: false, crossOriginTestExpect: false},
{allow: "'none'", sameOriginTestExpect: false, crossOriginTestExpect: false},
{allow: "'self' " + cross_origin + " https://www.example.com", sameOriginTestExpect: false, crossOriginTestExpect: 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, false);
}, 'Test frame policy on same origin iframe inherit from header policy.');
test(function() {
test_frame_policy('fullscreen', cross_origin_src, false);
}, 'Test frame policy on cross origin iframe inherit from header policy.');

// 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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';');
}, 'Test frame policy on cross 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,
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,
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, 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, policies[i].crossOriginTestExpect,
'fullscreen ' + policies[i].allow + ';', /*allowfullscreen*/true);
}, 'Test frame policy on cross origin iframe with allow = "' + policies[i].allow +
'" and allowfullscreen.');
}
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature-Policy: fullscreen 'none';
Loading