summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js')
-rw-r--r--testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js b/testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js
new file mode 100644
index 0000000000..821ebf69e3
--- /dev/null
+++ b/testing/web-platform/tests/fenced-frame/resources/default-enabled-features-helper.js
@@ -0,0 +1,45 @@
+// This is a helper file used for the attribution-reporting-*.https.html tests.
+// To use this, make sure you import these scripts:
+// <script src="/resources/testharness.js"></script>
+// <script src="/resources/testharnessreport.js"></script>
+// <script src="/common/utils.js"></script>
+// <script src="/common/dispatcher/dispatcher.js"></script>
+// <script src="resources/utils.js"></script>
+// <script src="/common/get-host-info.sub.js"></script>
+
+async function runDefaultEnabledFeaturesTest(t, should_load, fenced_origin,
+ generator_api="fledge", allow="") {
+ const fencedframe = await attachFencedFrameContext({
+ generator_api: generator_api,
+ attributes: [["allow", allow]],
+ origin: fenced_origin});
+
+ if (!should_load) {
+ const fencedframe_blocked = new Promise(r => t.step_timeout(r, 1000));
+ const fencedframe_loaded = fencedframe.execute(() => {});
+ assert_equals(await Promise.any([
+ fencedframe_blocked.then(() => "blocked"),
+ fencedframe_loaded.then(() => "loaded"),
+ ]), "blocked", "The fenced frame should not be loaded.");
+ return;
+ }
+
+ await fencedframe.execute((generator_api) => {
+ assert_true(
+ document.featurePolicy.allowsFeature('attribution-reporting'),
+ "Attribution reporting should be allowed if the fenced " +
+ "frame loaded using FLEDGE or shared storage.");
+
+ if (generator_api == "fledge") {
+ assert_false(
+ document.featurePolicy.allowsFeature('shared-storage'),
+ "Shared storage should be disallowed if the fenced " +
+ "frame loaded using FLEDGE.");
+ } else {
+ assert_true(
+ document.featurePolicy.allowsFeature('shared-storage'),
+ "Shared storage should be allowed if the fenced " +
+ "frame loaded using shared storage.");
+ }
+ }, [generator_api]);
+}