diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html b/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html new file mode 100644 index 00000000000000..defe06ffedbb88 --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html @@ -0,0 +1,84 @@ + + + + + + + + diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html.sub.headers b/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html.sub.headers new file mode 100644 index 00000000000000..111121a52fbdc9 --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-all.https.sub.html.sub.headers @@ -0,0 +1 @@ +Feature-Policy: fullscreen *; diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html b/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html new file mode 100644 index 00000000000000..d757d4c4cf518e --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html @@ -0,0 +1,84 @@ + + + + + + + + diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html.sub.headers b/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html.sub.headers new file mode 100644 index 00000000000000..0cc259b24f3829 --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-self.https.sub.html.sub.headers @@ -0,0 +1 @@ +Feature-Policy: fullscreen 'self'; diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html b/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html new file mode 100644 index 00000000000000..f10c66fe0e6133 --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html @@ -0,0 +1,109 @@ + + + + + + + + diff --git a/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html.sub.headers b/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html.sub.headers new file mode 100644 index 00000000000000..c2493a089031aa --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-allowed-for-some.https.sub.html.sub.headers @@ -0,0 +1 @@ +Feature-Policy: fullscreen 'self' https://{{domains[www]}}:{{ports[https][0]}} https://www.example.com; diff --git a/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html b/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html new file mode 100644 index 00000000000000..e1178e797d5257 --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html @@ -0,0 +1,84 @@ + + + + + + + + diff --git a/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html.sub.headers b/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html.sub.headers new file mode 100644 index 00000000000000..961d40336aeb3e --- /dev/null +++ b/feature-policy/feature-policy-frame-policy-disallowed-for-all.https.sub.html.sub.headers @@ -0,0 +1 @@ +Feature-Policy: fullscreen 'none'; diff --git a/feature-policy/resources/featurepolicy.js b/feature-policy/resources/featurepolicy.js index 925408ea8a4e50..be8629d153dc08 100644 --- a/feature-policy/resources/featurepolicy.js +++ b/feature-policy/resources/featurepolicy.js @@ -383,3 +383,33 @@ function test_subframe_header_policy( }); }, test_name); } + +// This function tests that frame policy allows a given feature correctly. A +// feature is allowed in a frame either through inherited policy or specified +// by iframe allow attribute. +// Arguments: +// feature: feature name. +// src: the URL to load in the frame. +// 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. +function test_frame_policy( + feature, src, test_expect, allow, allowfullscreen) { + let frame = document.createElement('iframe'); + document.body.appendChild(frame); + // frame_policy should be dynamically updated as allow and allowfullscreen is + // updated. + var frame_policy = frame.policy; + if (typeof allow !== 'undefined') { + frame.setAttribute('allow', allow); + } + if (!!allowfullscreen) { + frame.setAttribute('allowfullscreen', true); + } + frame.src = src; + if (test_expect) { + assert_true(frame_policy.allowedFeatures().includes(feature)); + } else { + assert_false(frame_policy.allowedFeatures().includes(feature)); + } +}