From a850b68cd853eed3dc17908d201d514823fc8128 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Thu, 31 May 2018 14:18:44 +0200 Subject: [PATCH 1/2] Fail early if Feature Policy is not supported 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..a4581a59a9c27b 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, 'document.policy'); +} // 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) { From 32135828714006badfaac1fcd41f55ad231c2433 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Mon, 11 Jun 2018 12:00:32 -0400 Subject: [PATCH 2/2] Fix nit --- feature-policy/resources/featurepolicy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-policy/resources/featurepolicy.js b/feature-policy/resources/featurepolicy.js index a4581a59a9c27b..55c7f98a8db31c 100644 --- a/feature-policy/resources/featurepolicy.js +++ b/feature-policy/resources/featurepolicy.js @@ -1,6 +1,6 @@ // Feature test to avoid timeouts function assert_feature_policy_supported() { - assert_not_equals(document.policy, undefined, 'document.policy'); + assert_not_equals(document.policy, undefined, 'Feature Policy is supported'); } // Tests whether a feature that is enabled/disabled by feature policy works // as expected.