summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html')
-rw-r--r--testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html75
1 files changed, 75 insertions, 0 deletions
diff --git a/testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html b/testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html
new file mode 100644
index 0000000000..1d7333d9b5
--- /dev/null
+++ b/testing/web-platform/tests/permissions/permissions-query-feature-policy-attribute.https.sub.html
@@ -0,0 +1,75 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Test permissions query againts feature policy allow attribute</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+
+<script>
+ "use strict";
+
+ function test_permissions_query(
+ feature_description, test, src, expect_state, allow_attribute) {
+ let frame = document.createElement('iframe');
+ frame.src = src;
+
+ if (typeof allow_attribute !== 'undefined') {
+ frame.allow = allow_attribute;
+ }
+
+ window.addEventListener('message', test.step_func(function handler(evt) {
+ if (evt.source === frame.contentWindow) {
+ assert_equals(evt.data.state, expect_state, feature_description);
+ document.body.removeChild(frame);
+ window.removeEventListener('message', handler);
+ test.done();
+ }
+ }));
+
+ document.body.appendChild(frame);
+ }
+
+ const same_origin_src =
+ "/permissions/feature-policy-permissions-query.html";
+ const cross_origin_src =
+ "https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
+
+ async_test(t => {
+ test_permissions_query(
+ 'navigator.permissions.query("geolocation")',
+ t,
+ same_origin_src,
+ "prompt",
+ "geolocation"
+ );
+ }, 'Permissions.state is "prompt" with allow="geolocation" in same-origin iframes.');
+
+ async_test(t => {
+ test_permissions_query(
+ 'navigator.permissions.query("geolocation")',
+ t,
+ cross_origin_src,
+ "prompt",
+ "geolocation"
+ );
+ }, 'Permissions.state is "prompt" with allow="geolocation" in cross-origin iframes.');
+
+ async_test(t => {
+ test_permissions_query(
+ 'navigator.permissions.query("geolocation")',
+ t,
+ same_origin_src,
+ "prompt"
+ );
+ }, 'Permission.state is "prompt" in same-origin iframes.');
+
+ async_test(t => {
+ test_permissions_query(
+ 'navigator.permissions.query("geolocation")',
+ t,
+ cross_origin_src,
+ "denied"
+ );
+ }, 'Permission.state is "denied" in cross-origin iframes.');
+
+</script>