diff options
Diffstat (limited to 'testing/web-platform/tests/browsing-topics/resources/check-topics-request-header-notify-parent.py')
-rw-r--r-- | testing/web-platform/tests/browsing-topics/resources/check-topics-request-header-notify-parent.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/web-platform/tests/browsing-topics/resources/check-topics-request-header-notify-parent.py b/testing/web-platform/tests/browsing-topics/resources/check-topics-request-header-notify-parent.py new file mode 100644 index 0000000000..98c77c2b0b --- /dev/null +++ b/testing/web-platform/tests/browsing-topics/resources/check-topics-request-header-notify-parent.py @@ -0,0 +1,18 @@ +def main(request, response): + """ + Returns an HTML response that notifies its parent frame the topics header + via postMessage + """ + + topics_header = request.headers.get(b"sec-browsing-topics", b"NO_TOPICS_HEADER") + + headers = [(b"Content-Type", b"text/html"), + (b"Access-Control-Allow-Origin", b"*")] + content = b''' +<script> + let parentOrOpener = window.opener || window.parent; + parentOrOpener.postMessage({ topicsHeader: '%s'}, "*"); +</script> +''' % (topics_header) + + return 200, headers, content |