From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/security/test/referrer-policy/browser.toml | 4 +- .../referrer-policy/browser_fragment_navigation.js | 42 ---------------- .../referrer-policy/browser_session_history.js | 57 ++++++++++++++++++++++ .../referrer-policy/file_fragment_navigation.sjs | 21 -------- .../test/referrer-policy/file_session_history.sjs | 27 ++++++++++ .../test/referrer-policy/referrer_helper.js | 4 +- .../test/referrer-policy/test_img_referrer.html | 4 +- 7 files changed, 90 insertions(+), 69 deletions(-) delete mode 100644 dom/security/test/referrer-policy/browser_fragment_navigation.js create mode 100644 dom/security/test/referrer-policy/browser_session_history.js delete mode 100644 dom/security/test/referrer-policy/file_fragment_navigation.sjs create mode 100644 dom/security/test/referrer-policy/file_session_history.sjs (limited to 'dom/security/test/referrer-policy') diff --git a/dom/security/test/referrer-policy/browser.toml b/dom/security/test/referrer-policy/browser.toml index 325b6a3f49..a77046c85b 100644 --- a/dom/security/test/referrer-policy/browser.toml +++ b/dom/security/test/referrer-policy/browser.toml @@ -1,8 +1,8 @@ [DEFAULT] support-files = ["referrer_page.sjs"] -["browser_fragment_navigation.js"] -support-files = ["file_fragment_navigation.sjs"] +["browser_session_history.js"] +support-files = ["file_session_history.sjs"] ["browser_referrer_disallow_cross_site_relaxing.js"] diff --git a/dom/security/test/referrer-policy/browser_fragment_navigation.js b/dom/security/test/referrer-policy/browser_fragment_navigation.js deleted file mode 100644 index c3d5e62854..0000000000 --- a/dom/security/test/referrer-policy/browser_fragment_navigation.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const TEST_FILE = - "https://example.com/browser/dom/security/test/referrer-policy/file_fragment_navigation.sjs"; - -add_task(async function test_browser_navigation() { - await BrowserTestUtils.withNewTab(TEST_FILE, async browser => { - let loadPromise = BrowserTestUtils.browserLoaded(browser); - await SpecialPowers.spawn(browser, [], () => { - ok(content.document.getElementById("ok"), "Initial page should load"); - - info("Clicking on link to check referrer"); - content.document.getElementById("check_referrer").click(); - }); - await loadPromise; - - await SpecialPowers.spawn(browser, [], () => { - ok( - content.document.getElementById("ok"), - "Page should load when checking referrer" - ); - - info("Clicking on fragment link"); - content.document.getElementById("fragment").click(); - }); - - info("Reloading tab"); - loadPromise = BrowserTestUtils.browserLoaded(browser); - await BrowserTestUtils.reloadTab(gBrowser.selectedTab); - await loadPromise; - - await SpecialPowers.spawn(browser, [], () => { - ok( - content.document.getElementById("ok"), - "Page should load when checking referrer after fragment navigation and reload" - ); - }); - }); -}); diff --git a/dom/security/test/referrer-policy/browser_session_history.js b/dom/security/test/referrer-policy/browser_session_history.js new file mode 100644 index 0000000000..b480ce4ff0 --- /dev/null +++ b/dom/security/test/referrer-policy/browser_session_history.js @@ -0,0 +1,57 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const TEST_FILE = + "https://example.com/browser/dom/security/test/referrer-policy/file_session_history.sjs"; + +add_task(async function test_browser_navigation() { + await BrowserTestUtils.withNewTab(TEST_FILE, async browser => { + let loadPromise = BrowserTestUtils.browserLoaded(browser); + await SpecialPowers.spawn(browser, [], () => { + ok(content.document.getElementById("ok"), "Initial page should load"); + + info("Clicking on link to check referrer"); + content.document.getElementById("check_referrer").click(); + }); + await loadPromise; + + await SpecialPowers.spawn(browser, [], () => { + ok( + content.document.getElementById("ok"), + "Page should load when checking referrer" + ); + + info("Clicking on fragment link"); + content.document.getElementById("fragment").click(); + }); + + info("Reloading tab"); + loadPromise = BrowserTestUtils.browserLoaded(browser); + await BrowserTestUtils.reloadTab(gBrowser.selectedTab); + await loadPromise; + + await SpecialPowers.spawn(browser, [], () => { + ok( + content.document.getElementById("ok"), + "Page should load when checking referrer after fragment navigation and reload" + ); + + info("Clicking on push_state button"); + content.document.getElementById("push_state").click(); + }); + + info("Reloading tab"); + loadPromise = BrowserTestUtils.browserLoaded(browser); + await BrowserTestUtils.reloadTab(gBrowser.selectedTab); + await loadPromise; + + await SpecialPowers.spawn(browser, [], () => { + ok( + content.document.getElementById("ok"), + "Page should load when checking referrer after history.pushState and reload" + ); + }); + }); +}); diff --git a/dom/security/test/referrer-policy/file_fragment_navigation.sjs b/dom/security/test/referrer-policy/file_fragment_navigation.sjs deleted file mode 100644 index 5fb6f0d826..0000000000 --- a/dom/security/test/referrer-policy/file_fragment_navigation.sjs +++ /dev/null @@ -1,21 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function handleRequest(request, response) { - if ( - request.queryString === "check_referrer" && - (!request.hasHeader("referer") || - request.getHeader("referer") !== - "https://example.com/browser/dom/security/test/referrer-policy/file_fragment_navigation.sjs") - ) { - response.setStatusLine(request.httpVersion, 400, "Bad Request"); - response.write("Did not receive referrer"); - } else { - response.setHeader("Content-Type", "text/html"); - response.write( - `OK -check_referrer -fragment` - ); - } -} diff --git a/dom/security/test/referrer-policy/file_session_history.sjs b/dom/security/test/referrer-policy/file_session_history.sjs new file mode 100644 index 0000000000..3d5f06b026 --- /dev/null +++ b/dom/security/test/referrer-policy/file_session_history.sjs @@ -0,0 +1,27 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function handleRequest(request, response) { + if ( + request.queryString === "check_referrer" && + (!request.hasHeader("referer") || + request.getHeader("referer") !== + "https://example.com/browser/dom/security/test/referrer-policy/file_session_history.sjs") + ) { + response.setStatusLine(request.httpVersion, 400, "Bad Request"); + response.write("Did not receive referrer"); + } else { + response.setHeader("Content-Type", "text/html"); + response.write( + `OK + check_referrer + fragment + + ` + ); + } +} diff --git a/dom/security/test/referrer-policy/referrer_helper.js b/dom/security/test/referrer-policy/referrer_helper.js index b892017eef..92593fa907 100644 --- a/dom/security/test/referrer-policy/referrer_helper.js +++ b/dom/security/test/referrer-policy/referrer_helper.js @@ -61,7 +61,7 @@ function checkIndividualResults(aTestname, aExpectedReferrer, aName) { ); advance(); }; - var onerror = xhr => { + var onerror = () => { ok(false, "Can't get results from the counter server."); SimpleTest.finish(); }; @@ -69,7 +69,7 @@ function checkIndividualResults(aTestname, aExpectedReferrer, aName) { } function resetState() { - doXHR(RESET_STATE, advance, function (xhr) { + doXHR(RESET_STATE, advance, function () { ok(false, "error in reset state"); SimpleTest.finish(); }); diff --git a/dom/security/test/referrer-policy/test_img_referrer.html b/dom/security/test/referrer-policy/test_img_referrer.html index fcc80929d2..5e3a2e6ddf 100644 --- a/dom/security/test/referrer-policy/test_img_referrer.html +++ b/dom/security/test/referrer-policy/test_img_referrer.html @@ -64,7 +64,7 @@ function checkIndividualResults(aTestname, aExpectedImg, aName) { advance(); }, - function(xhr) { + function() { ok(false, "Can't get results from the counter server."); SimpleTest.finish(); }); @@ -73,7 +73,7 @@ function checkIndividualResults(aTestname, aExpectedImg, aName) { function resetState() { doXHR('/tests/dom/security/test/referrer-policy/img_referrer_testserver.sjs?action=resetState', advance, - function(xhr) { + function() { ok(false, "error in reset state"); SimpleTest.finish(); }); -- cgit v1.2.3