From 3d007777eea4dd5dab62a0e079017c64ebb439b0 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Thu, 22 Apr 2021 11:58:19 +0000 Subject: [PATCH] Bug 1706577: HTTPS-First should handle fragment navigation correctly. r=JulianWels Differential Revision: https://phabricator.services.mozilla.com/D113107 --- dom/security/nsHTTPSOnlyUtils.cpp | 3 +- .../test/https-first/file_fragment.html | 42 ++++++++++++++ dom/security/test/https-first/mochitest.ini | 4 ++ .../test/https-first/test_fragment.html | 58 +++++++++++++++++++ dom/security/test/moz.build | 1 + 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 dom/security/test/https-first/file_fragment.html create mode 100644 dom/security/test/https-first/mochitest.ini create mode 100644 dom/security/test/https-first/test_fragment.html diff --git a/dom/security/nsHTTPSOnlyUtils.cpp b/dom/security/nsHTTPSOnlyUtils.cpp index aa65051d6891..f801cc0f4108 100644 --- a/dom/security/nsHTTPSOnlyUtils.cpp +++ b/dom/security/nsHTTPSOnlyUtils.cpp @@ -615,7 +615,8 @@ bool nsHTTPSOnlyUtils::IsEqualURIExceptSchemeAndRef(nsIURI* aHTTPSSchemeURI, // 3. Check if the HTTPS-Only Mode is even enabled, before we do anything else bool isPrivateWin = aLoadInfo->GetOriginAttributes().mPrivateBrowsingId > 0; - if (!IsHttpsOnlyModeEnabled(isPrivateWin)) { + if (!IsHttpsOnlyModeEnabled(isPrivateWin) && + !IsHttpsFirstModeEnabled(isPrivateWin)) { return false; } diff --git a/dom/security/test/https-first/file_fragment.html b/dom/security/test/https-first/file_fragment.html new file mode 100644 index 000000000000..4d042ebc15d4 --- /dev/null +++ b/dom/security/test/https-first/file_fragment.html @@ -0,0 +1,42 @@ + + + + + Click me +
space
+ foo +
space
+ + diff --git a/dom/security/test/https-first/mochitest.ini b/dom/security/test/https-first/mochitest.ini new file mode 100644 index 000000000000..ca2cbd41cf41 --- /dev/null +++ b/dom/security/test/https-first/mochitest.ini @@ -0,0 +1,4 @@ +[DEFAULT] + +[test_fragment.html] +support-files = file_fragment.html diff --git a/dom/security/test/https-first/test_fragment.html b/dom/security/test/https-first/test_fragment.html new file mode 100644 index 000000000000..63a7affee202 --- /dev/null +++ b/dom/security/test/https-first/test_fragment.html @@ -0,0 +1,58 @@ + + + +Bug 1706577: Have https-first mode account for fragment navigations + + + + + + + + diff --git a/dom/security/test/moz.build b/dom/security/test/moz.build index 85b2cc8fa58e..0fb27de75208 100644 --- a/dom/security/test/moz.build +++ b/dom/security/test/moz.build @@ -19,6 +19,7 @@ MOCHITEST_MANIFESTS += [ "cors/mochitest.ini", "csp/mochitest.ini", "general/mochitest.ini", + "https-first/mochitest.ini", "https-only/mochitest.ini", "mixedcontentblocker/mochitest.ini", "referrer-policy/mochitest.ini",