diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js | |
parent | Initial commit. (diff) | |
download | firefox-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/browsing-topics/resources/navigation-header-util.sub.js')
-rw-r--r-- | testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js b/testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js new file mode 100644 index 0000000000..b3bec79651 --- /dev/null +++ b/testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js @@ -0,0 +1,36 @@ +function test_topics_iframe_navigation_header( + test, has_browsing_topics_attribute, is_same_origin, expect_topics_header_available_func) { + const same_origin_src = '/browsing-topics/resources/check-topics-request-header-notify-parent.py'; + 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; + + if (has_browsing_topics_attribute) { + frame.browsingTopics = true; + } + + window.addEventListener('message', test.step_func(function handler(evt) { + if (evt.source === frame.contentWindow) { + expect_topics_header_available_func(evt.data); + + document.body.removeChild(frame); + window.removeEventListener('message', handler); + test.done(); + } + })); + + document.body.appendChild(frame); +} + +function expect_topics_header_unavailable(data) { + assert_equals(data.topicsHeader, 'NO_TOPICS_HEADER'); +} + +function expect_topics_header_available(data) { + // An empty result indicates that the request was eligible for topics. + // Currently, the web-platform-tests framework does not support actually + // handling the topics request. + assert_equals(data.topicsHeader, ''); +}
\ No newline at end of file |