summaryrefslogtreecommitdiffstats
path: root/caps/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /caps/tests
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'caps/tests')
-rw-r--r--caps/tests/gtest/TestScriptSecurityManager.cpp50
-rw-r--r--caps/tests/gtest/moz.build1
-rw-r--r--caps/tests/mochitest/test_addonMayLoad.html2
-rw-r--r--caps/tests/mochitest/test_bug995943.xhtml2
4 files changed, 53 insertions, 2 deletions
diff --git a/caps/tests/gtest/TestScriptSecurityManager.cpp b/caps/tests/gtest/TestScriptSecurityManager.cpp
new file mode 100644
index 0000000000..b2af5c3023
--- /dev/null
+++ b/caps/tests/gtest/TestScriptSecurityManager.cpp
@@ -0,0 +1,50 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include "gtest/gtest.h"
+
+#include "nsCOMPtr.h"
+#include "nsIURI.h"
+#include "nsNetUtil.h"
+#include "nsScriptSecurityManager.h"
+
+namespace mozilla {
+
+TEST(ScriptSecurityManager, IsHttpOrHttpsAndCrossOrigin)
+{
+ nsCOMPtr<nsIURI> uriA;
+ NS_NewURI(getter_AddRefs(uriA), "https://apple.com");
+ nsCOMPtr<nsIURI> uriB;
+ NS_NewURI(getter_AddRefs(uriB), "https://google.com");
+ nsCOMPtr<nsIURI> uriB_http;
+ NS_NewURI(getter_AddRefs(uriB_http), "http://google.com");
+ nsCOMPtr<nsIURI> aboutBlank;
+ NS_NewURI(getter_AddRefs(aboutBlank), "about:blank");
+ nsCOMPtr<nsIURI> aboutConfig;
+ NS_NewURI(getter_AddRefs(aboutConfig), "about:config");
+ nsCOMPtr<nsIURI> example_com;
+ NS_NewURI(getter_AddRefs(example_com), "https://example.com");
+ nsCOMPtr<nsIURI> example_com_with_path;
+ NS_NewURI(getter_AddRefs(example_com_with_path),
+ "https://example.com/test/1/2/3");
+ nsCOMPtr<nsIURI> nullURI = nullptr;
+
+ ASSERT_TRUE(nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(uriA, uriB));
+ ASSERT_TRUE(
+ nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(uriB, uriB_http));
+
+ ASSERT_FALSE(nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(
+ aboutBlank, aboutConfig));
+ ASSERT_FALSE(nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(
+ aboutBlank, aboutBlank));
+ ASSERT_FALSE(
+ nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(uriB, aboutConfig));
+ ASSERT_FALSE(nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(
+ example_com, example_com_with_path));
+ ASSERT_FALSE(
+ nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(uriB_http, nullURI));
+ ASSERT_FALSE(
+ nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(nullURI, uriB_http));
+}
+
+} // namespace mozilla
diff --git a/caps/tests/gtest/moz.build b/caps/tests/gtest/moz.build
index 10b1a66f3b..c0e2087fc2 100644
--- a/caps/tests/gtest/moz.build
+++ b/caps/tests/gtest/moz.build
@@ -11,6 +11,7 @@ UNIFIED_SOURCES += [
"TestPrincipalAttributes.cpp",
"TestPrincipalSerialization.cpp",
"TestRedirectChainURITruncation.cpp",
+ "TestScriptSecurityManager.cpp",
]
include("/ipc/chromium/chromium-config.mozbuild")
diff --git a/caps/tests/mochitest/test_addonMayLoad.html b/caps/tests/mochitest/test_addonMayLoad.html
index 2d5e5e59f1..74dc8134b4 100644
--- a/caps/tests/mochitest/test_addonMayLoad.html
+++ b/caps/tests/mochitest/test_addonMayLoad.html
@@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1180921
baseURL: `file:///{id}`,
allowedOrigins: new MatchPatternSet([`*://${subdomain}.example.org/*`]),
- localizeCallback(string) {},
+ localizeCallback() {},
});
}
diff --git a/caps/tests/mochitest/test_bug995943.xhtml b/caps/tests/mochitest/test_bug995943.xhtml
index 0ba95f548d..fc7c0b022f 100644
--- a/caps/tests/mochitest/test_bug995943.xhtml
+++ b/caps/tests/mochitest/test_bug995943.xhtml
@@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=995943
function checkLoadFileURI(domain, shouldLoad) {
debug("Invoking checkLoadFileURI with domain: " + domain + ", shouldLoad: " + shouldLoad);
- return new Promise(function(resolve, reject) {
+ return new Promise(function(resolve) {
$('ifr').addEventListener('load', function l1() {
debug("Invoked l1 for " + domain);
$('ifr').removeEventListener('load', l1);