diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js')
-rw-r--r-- | testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js b/testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js new file mode 100644 index 0000000000..e8bf45049c --- /dev/null +++ b/testing/web-platform/tests/browsing-topics/resources/permissions-policy-util.sub.js @@ -0,0 +1,30 @@ +const TOPICS_PERMISSIONS_POLICY_ERROR_MESSAGE = 'The \"browsing-topics\" Permissions Policy denied the use of document.browsingTopics().'; + +function test_topics_feature_availability_in_subframe(test, is_same_origin, expect_feature_available_func) { + const same_origin_src = '/browsing-topics/resources/document-api-notify-parent.tentative.https.html'; + const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' + + same_origin_src; + + let frame = document.createElement('iframe'); + frame.src = is_same_origin ? same_origin_src : cross_origin_src; + + window.addEventListener('message', test.step_func(function handler(evt) { + if (evt.source === frame.contentWindow) { + expect_feature_available_func(evt.data); + + document.body.removeChild(frame); + window.removeEventListener('message', handler); + test.done(); + } + })); + + document.body.appendChild(frame); +} + +function expect_topics_feature_unavailable(data) { + assert_equals(data.error, TOPICS_PERMISSIONS_POLICY_ERROR_MESSAGE); +} + +function expect_topics_feature_available(data) { + assert_equals(data.error, 'No error'); +} |