From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- dom/base/test/iframe_meta_refresh.sjs | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 dom/base/test/iframe_meta_refresh.sjs (limited to 'dom/base/test/iframe_meta_refresh.sjs') diff --git a/dom/base/test/iframe_meta_refresh.sjs b/dom/base/test/iframe_meta_refresh.sjs new file mode 100644 index 0000000000..0d881be72b --- /dev/null +++ b/dom/base/test/iframe_meta_refresh.sjs @@ -0,0 +1,92 @@ +/* + * Test server for iframe refresh from meta http-equiv + */ + +const SHARED_KEY = "iframe_meta_refresh"; +const DEFAULT_STATE = { count: 0, referrers: [] }; +const REFRESH_PAGE = + "http://example.com/tests/dom/base/test/iframe_meta_refresh.sjs?action=test"; + +function createContent(refresh) { + let metaRefresh = ""; + let scriptMessage = ""; + + if (refresh) { + metaRefresh = ``; + } else { + scriptMessage = ` + `; + } + + return ` + + + + ${metaRefresh} + Test referrer of meta http-equiv refresh + + + ${scriptMessage} + + `; +} + +function handleRequest(request, response) { + Components.utils.importGlobalProperties(["URLSearchParams"]); + let query = new URLSearchParams(request.queryString); + + let action = query.get("action"); + + var referrerLevel = "none"; + if (request.hasHeader("Referer")) { + let referrer = request.getHeader("Referer"); + if (referrer.indexOf("test_meta_refresh_referrer") > 0) { + referrerLevel = "full"; + } else if (referrer == "http://mochi.test:8888/") { + referrerLevel = "origin"; + } + } + + var state = getSharedState(SHARED_KEY); + if (state === "") { + state = DEFAULT_STATE; + } else { + state = JSON.parse(state); + } + + response.setStatusLine(request.httpVersion, 200, "OK"); + + //avoid confusing cache behaviors + response.setHeader("Cache-Control", "no-cache", false); + + if (action === "results") { + response.setHeader("Content-Type", "text/plain", false); + response.write(JSON.stringify(state)); + return; + } + + if (action === "reset") { + //reset server state + setSharedState(SHARED_KEY, JSON.stringify(DEFAULT_STATE)); + response.write(""); + return; + } + + if (action === "test") { + let load = query.get("load"); + state.count++; + if (state.referrers.indexOf(referrerLevel) < 0) { + state.referrers.push(referrerLevel); + } + + // Write frame content + response.write(createContent(load)); + } + + setSharedState(SHARED_KEY, JSON.stringify(state)); + return; +} -- cgit v1.2.3