summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/compute-pressure/permissions-policy
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/compute-pressure/permissions-policy
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/compute-pressure/permissions-policy')
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute-redirect-on-load.https.html39
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute.https.html37
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html55
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html44
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-default-permissions-policy.https.html34
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html62
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-supported-by-permissions-policy.html11
10 files changed, 285 insertions, 0 deletions
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute-redirect-on-load.https.html
new file mode 100644
index 0000000000..ec5b464461
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute-redirect-on-load.https.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const relative_path =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const base_src = '/permissions-policy/resources/redirect-on-load.html#';
+const same_origin_src = base_src + relative_path;
+const cross_origin_src =
+ base_src + get_host_info().HTTPS_REMOTE_ORIGIN + relative_path;
+const header = 'permissions policy allow="compute-pressure"';
+
+async_test(t => {
+ test_feature_availability(
+ 'PressureObserver.observe()',
+ t,
+ same_origin_src,
+ expect_feature_available_default,
+ 'compute-pressure'
+ );
+}, `${header} allows same-origin navigation in an iframe.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'PressureObserver.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default,
+ 'compute-pressure'
+ );
+}, `${header} disallows cross-origin navigation in an iframe.`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute.https.html
new file mode 100644
index 0000000000..d6dfcfc191
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy-attribute.https.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const same_origin_src =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const cross_origin_src = get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;
+const feature_name = 'permissions policy "compute-pressure"';
+const attribute = 'allow="compute-pressure" attribute';
+
+async_test(t => {
+ test_feature_availability(
+ 'PressureObserver.observe()',
+ t,
+ same_origin_src,
+ expect_feature_available_default,
+ 'compute-pressure'
+ );
+}, `${feature_name} can be enabled in same-origin iframe using ${attribute}`);
+
+async_test(t => {
+ test_feature_availability(
+ 'PressureObserver.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_available_default,
+ 'compute-pressure'
+ );
+}, `${feature_name} can be enabled in cross-origin iframe using ${attribute}`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html
new file mode 100644
index 0000000000..1651f72612
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const same_origin_src =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const cross_origin_src = get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;
+const header = 'permissions policy header "compute-pressure=*"';
+const attribute = 'allow="compute-pressure" attribute';
+
+promise_test(async () => {
+ try {
+ const observer = new PressureObserver(() => {});
+ await observer.observe("cpu");
+ observer.disconnect();
+ } catch (e) {
+ assert_unreached("expected promise to resolve.");
+ }
+}, `${header} allows the top-level document.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ same_origin_src,
+ expect_feature_available_default
+ );
+}, `${header} allows same-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default
+ );
+}, `${header} disallows cross-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_available_default,
+ 'compute-pressure'
+ );
+}, `${header} allows cross-origin iframes with ${attribute}.`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html.headers b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html.headers
new file mode 100644
index 0000000000..76185cbb2d
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-by-permissions-policy.https.html.headers
@@ -0,0 +1 @@
+Permissions-Policy: compute-pressure=*
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html
new file mode 100644
index 0000000000..98450b91a7
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const same_origin_src =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const cross_origin_src = get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;
+const header = 'permissions policy header "compute-pressure=self"';
+
+promise_test(async () => {
+ try {
+ const observer = new PressureObserver(() => {});
+ await observer.observe("cpu");
+ observer.disconnect();
+ } catch (e) {
+ assert_unreached('expected promise to resolve.');
+ }
+}, `${header} allows the top-level document.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ same_origin_src,
+ expect_feature_available_default
+ );
+}, `${header} allows same-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default
+ );
+}, `${header} disallows cross-origin iframes.`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html.headers b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html.headers
new file mode 100644
index 0000000000..6852f871bb
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-allowed-on-self-origin-by-permissions-policy.https.html.headers
@@ -0,0 +1 @@
+Permissions-Policy: compute-pressure=self
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-default-permissions-policy.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-default-permissions-policy.https.html
new file mode 100644
index 0000000000..5a7c77264e
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-default-permissions-policy.https.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const same_origin_src =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const cross_origin_src = get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;
+const header = 'Default "compute-pressure" permissions policy';
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ same_origin_src,
+ expect_feature_available_default
+ );
+}, `${header} allows same-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default
+ );
+}, `${header} disallows cross-origin iframes.`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html
new file mode 100644
index 0000000000..58b044247c
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+"use strict";
+
+const same_origin_src =
+ '/permissions-policy/resources/permissions-policy-compute-pressure.html';
+const cross_origin_src = get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;
+const header = 'permissions policy header "compute-pressure=()"';
+const attribute = 'allow="compute-pressure" attribute';
+
+promise_test(async t => {
+ const observer = new PressureObserver(
+ t.unreached_func('oops should not end up here')
+ );
+ await promise_rejects_dom(t, 'NotAllowedError', observer.observe("cpu"));
+}, `${header} disallows the top-level document.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ same_origin_src,
+ expect_feature_unavailable_default
+ );
+}, `${header} disallows same-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default
+ );
+}, `${header} disallows cross-origin iframes.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ same_origin_src,
+ expect_feature_unavailable_default,
+ 'compute-pressure'
+ );
+}, `${header} disallows same-origin iframes despite the ${attribute}.`);
+
+async_test(t => {
+ test_feature_availability(
+ 'ComputePressure.observe()',
+ t,
+ cross_origin_src,
+ expect_feature_unavailable_default,
+ 'compute-pressure'
+ );
+}, `${header} disallows cross-origin iframes despite the ${attribute}.`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html.headers b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html.headers
new file mode 100644
index 0000000000..2e9f2ecce0
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-disabled-by-permissions-policy.https.html.headers
@@ -0,0 +1 @@
+Permissions-Policy: compute-pressure=()
diff --git a/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-supported-by-permissions-policy.html b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-supported-by-permissions-policy.html
new file mode 100644
index 0000000000..931fcb66b4
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/permissions-policy/compute-pressure-supported-by-permissions-policy.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<title>Test that compute-pressure is advertised in the feature list</title>
+<link rel="help" href="https://w3c.github.io/webappsec-permissions-policy/#dom-permissions-policy-features">
+<link rel="help" href="https://wicg.github.io/compute-pressure/#policy-control">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ assert_in_array('compute-pressure', document.featurePolicy.features());
+}, 'document.featurePolicy.features should advertise compute-pressure.');
+</script>