Skip to content

Commit

Permalink
Fail early if Feature Policy is not supported
Browse files Browse the repository at this point in the history
Part of #11269.
  • Loading branch information
zcorpan committed May 31, 2018
1 parent 730415d commit a850b68
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions feature-policy/resources/featurepolicy.js
@@ -1,3 +1,7 @@
// Feature test to avoid timeouts
function assert_feature_policy_supported() {
assert_not_equals(document.policy, undefined, 'document.policy');
}
// 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

0 comments on commit a850b68

Please sign in to comment.