From 73f8f236d53c825f4ed2fbe6379ce04a56e7a865 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Thu, 14 Jun 2018 08:43:34 -0400 Subject: [PATCH] Fail early if Feature Policy is not supported (#11270) Part of #11269. --- feature-policy/resources/featurepolicy.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/feature-policy/resources/featurepolicy.js b/feature-policy/resources/featurepolicy.js index bf7693fd1b96a8..55c7f98a8db31c 100644 --- a/feature-policy/resources/featurepolicy.js +++ b/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, 'Feature Policy is supported'); +} // Tests whether a feature that is enabled/disabled by feature policy works // as expected. // Arguments: @@ -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) { @@ -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) { @@ -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) {