From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/browser/coop_header.sjs | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 toolkit/components/remotebrowserutils/tests/browser/coop_header.sjs (limited to 'toolkit/components/remotebrowserutils/tests/browser/coop_header.sjs') diff --git a/toolkit/components/remotebrowserutils/tests/browser/coop_header.sjs b/toolkit/components/remotebrowserutils/tests/browser/coop_header.sjs new file mode 100644 index 0000000000..03ed73af76 --- /dev/null +++ b/toolkit/components/remotebrowserutils/tests/browser/coop_header.sjs @@ -0,0 +1,57 @@ +function handleRequest(request, response) { + let query = new URLSearchParams(request.queryString); + + response.setStatusLine(request.httpVersion, 200, "OK"); + + // The tests for Cross-Origin-Opener-Policy unfortunately depend on + // BFCacheInParent not kicking in, as with that enabled, it is not possible to + // tell whether the BrowsingContext switch was caused by the BFCache + // navigation or by the COOP mismatch. This header disables BFCache for the + // coop documents, and should avoid the issue. + response.setHeader("Cache-Control", "no-store", false); + + let isDownloadPage = false; + let isDownloadFile = false; + + query.forEach((value, name) => { + if (name === "downloadPage") { + isDownloadPage = true; + } else if (name === "downloadFile") { + isDownloadFile = true; + } else if (name == "coop") { + response.setHeader("Cross-Origin-Opener-Policy", unescape(value), false); + } else if (name == "coep") { + response.setHeader( + "Cross-Origin-Embedder-Policy", + unescape(value), + false + ); + } + }); + + let downloadHTML = ""; + if (isDownloadPage) { + ["no-coop", "same-origin", "same-origin-allow-popups"].forEach(coop => { + downloadHTML += + '' + + unescape(coop) + + "
"; + }); + } + + if (isDownloadFile) { + response.setHeader("Content-Type", "application/octet-stream", false); + response.write("BINARY_DATA"); + } else { + response.setHeader("Content-Type", "text/html; charset=utf-8", false); + response.write( + "

Hello world

" + + downloadHTML + + "" + ); + } +} -- cgit v1.2.3