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

Fail early if Feature Policy is not supported #11270

Merged
merged 2 commits into from
Jun 14, 2018
Merged
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
7 changes: 7 additions & 0 deletions feature-policy/resources/featurepolicy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Feature test to avoid timeouts
function assert_feature_policy_supported() {
assert_not_equals(document.policy, undefined, 'Feature Policy is supported');
}
// Tests whether a feature that is enabled/disabled by feature policy works
// as expected.
// Arguments:
Expand Down Expand Up @@ -279,6 +283,7 @@ function test_allowed_feature_for_subframe(message, feature, src, allow) {
frame.allow = allow;
}
promise_test(function() {
assert_feature_policy_supported();
frame.src = src;
return new Promise(function(resolve, reject) {
window.addEventListener('message', function handler(evt) {
Expand All @@ -305,6 +310,7 @@ function test_disallowed_feature_for_subframe(message, feature, src, allow) {
frame.allow = allow;
}
promise_test(function() {
assert_feature_policy_supported();
frame.src = src;
return new Promise(function(resolve, reject) {
window.addEventListener('message', function handler(evt) {
Expand Down Expand Up @@ -333,6 +339,7 @@ function test_subframe_header_policy(
feature, frame_header_policy, src, test_expects, test_name) {
let frame = document.createElement('iframe');
promise_test(function() {
assert_feature_policy_supported()
frame.src = src + '?pipe=sub|header(Feature-Policy,' + feature + ' '
+ frame_header_policy + ';)';
return new Promise(function(resolve, reject) {
Expand Down