From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../resources/navigation-header-util.sub.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js (limited to 'testing/web-platform/tests/browsing-topics/resources/navigation-header-util.sub.js') 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 -- cgit v1.2.3