diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 5d7da2139f43..c842bb134d0f 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -554949,7 +554949,7 @@ "support" ], "feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html": [ - "7a68af16b8cb8292185997cefdfeb3be295813a7", + "fdc37b6a3d16b35095a05b2857faeaf3d28c1feb", "testharness" ], "feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html.sub.headers": [ @@ -555129,7 +555129,7 @@ "support" ], "feature-policy/resources/featurepolicy.js": [ - "87607362a81716400d9fee10958893e7a785f74e", + "a95ee6fc23217f5fc271763f5363a09b0ff04537", "support" ], "feature-policy/resources/picture-in-picture.js": [ diff --git a/testing/web-platform/tests/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html b/testing/web-platform/tests/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html index d757d4c4cf51..d71a09f9a9a7 100644 --- a/testing/web-platform/tests/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html +++ b/testing/web-platform/tests/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html @@ -28,6 +28,24 @@ test_frame_policy('fullscreen', cross_origin_src, false); }, 'Test frame policy on cross origin iframe inherit from header policy.'); + // Test that frame policy can be used for sandboxed frames + test(function() { + test_frame_policy( + 'fullscreen', same_origin_src, false, undefined, false, true); + }, 'Test frame policy on sandboxed iframe with no allow attribute.'); + test(function() { + test_frame_policy( + 'fullscreen', same_origin_src, true, 'fullscreen', false, true); + }, 'Test frame policy on sandboxed iframe with allow="fullscreen".'); + test(function() { + test_frame_policy( + 'fullscreen', same_origin_src, true, 'fullscreen \'src\'', false, true); + }, 'Test frame policy on sandboxed iframe with allow="fullscreen \'src\'".'); + test(function() { + test_frame_policy( + 'fullscreen', cross_origin_src, false, 'fullscreen ' + cross_origin, false, true); + }, 'Test frame policy on sandboxed iframe with allow="fullscreen ' + cross_origin + '".'); + // Test frame policy with allow attribute set to be one of the policies above. for (var i = 0; i < policies.length; i++) { test(function() { diff --git a/testing/web-platform/tests/feature-policy/resources/featurepolicy.js b/testing/web-platform/tests/feature-policy/resources/featurepolicy.js index be8629d153dc..bf7693fd1b96 100644 --- a/testing/web-platform/tests/feature-policy/resources/featurepolicy.js +++ b/testing/web-platform/tests/feature-policy/resources/featurepolicy.js @@ -393,8 +393,10 @@ function test_subframe_header_policy( // test_expect: boolean value of whether the feature should be allowed. // allow: optional, the allow attribute (container policy) of the iframe. // allowfullscreen: optional, boolean value of allowfullscreen attribute. +// sandbox: optional boolean. If true, the frame will be sandboxed (with +// allow-scripts, so that tests can run in it.) function test_frame_policy( - feature, src, test_expect, allow, allowfullscreen) { + feature, src, test_expect, allow, allowfullscreen, sandbox) { let frame = document.createElement('iframe'); document.body.appendChild(frame); // frame_policy should be dynamically updated as allow and allowfullscreen is @@ -406,6 +408,9 @@ function test_frame_policy( if (!!allowfullscreen) { frame.setAttribute('allowfullscreen', true); } + if (!!sandbox) { + frame.setAttribute('sandbox', 'allow-scripts'); + } frame.src = src; if (test_expect) { assert_true(frame_policy.allowedFeatures().includes(feature));