summaryrefslogtreecommitdiffstats
path: root/netwerk/test/gtest
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/test/gtest')
-rw-r--r--netwerk/test/gtest/TestCommon.h8
-rw-r--r--netwerk/test/gtest/TestCookie.cpp4
-rw-r--r--netwerk/test/gtest/TestIDNA.cpp43
-rw-r--r--netwerk/test/gtest/TestInputStreamTransport.cpp2
-rw-r--r--netwerk/test/gtest/TestNamedPipeService.cpp2
-rw-r--r--netwerk/test/gtest/moz.build14
6 files changed, 53 insertions, 20 deletions
diff --git a/netwerk/test/gtest/TestCommon.h b/netwerk/test/gtest/TestCommon.h
index 0d2fd74e5b..76620fbb44 100644
--- a/netwerk/test/gtest/TestCommon.h
+++ b/netwerk/test/gtest/TestCommon.h
@@ -17,8 +17,8 @@ class WaitForCondition final : public nsIRunnable {
NS_DECL_THREADSAFE_ISUPPORTS
void Wait(int pending) {
- MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(mPending == 0);
+ MOZ_RELEASE_ASSERT(NS_IsMainThread());
+ MOZ_RELEASE_ASSERT(mPending == 0);
mPending = pending;
mozilla::SpinEventLoopUntil("TestCommon.h:WaitForCondition::Wait"_ns,
@@ -32,8 +32,8 @@ class WaitForCondition final : public nsIRunnable {
virtual ~WaitForCondition() = default;
NS_IMETHOD Run() override {
- MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(mPending);
+ MOZ_RELEASE_ASSERT(NS_IsMainThread());
+ MOZ_RELEASE_ASSERT(mPending);
--mPending;
return NS_OK;
diff --git a/netwerk/test/gtest/TestCookie.cpp b/netwerk/test/gtest/TestCookie.cpp
index 4812ee47f1..e99e9f6332 100644
--- a/netwerk/test/gtest/TestCookie.cpp
+++ b/netwerk/test/gtest/TestCookie.cpp
@@ -95,7 +95,7 @@ void SetACookieInternal(nsICookieService* aCookieService, const char* aSpec,
/* shouldResistFingerprinting */ false)
: CookieJarSettings::GetBlockingAll(
/* shouldResistFingerprinting */ false);
- MOZ_ASSERT(cookieJarSettings);
+ MOZ_RELEASE_ASSERT(cookieJarSettings);
nsCOMPtr<nsILoadInfo> loadInfo = dummyChannel->LoadInfo();
loadInfo->SetCookieJarSettings(cookieJarSettings);
@@ -140,7 +140,7 @@ void GetACookieNoHttp(nsICookieService* aCookieService, const char* aSpec,
RefPtr<BasePrincipal> principal =
BasePrincipal::CreateContentPrincipal(uri, OriginAttributes());
- MOZ_ASSERT(principal);
+ MOZ_RELEASE_ASSERT(principal);
nsCOMPtr<mozilla::dom::Document> document;
nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
diff --git a/netwerk/test/gtest/TestIDNA.cpp b/netwerk/test/gtest/TestIDNA.cpp
index 544debbd43..56b05025d7 100644
--- a/netwerk/test/gtest/TestIDNA.cpp
+++ b/netwerk/test/gtest/TestIDNA.cpp
@@ -3,6 +3,9 @@
#include "gtest/BlackBox.h"
#include "nsNetUtil.h"
+#include "nsIURI.h"
+#include "nsCOMPtr.h"
+#include "mozilla/Encoding.h"
#define TEST_COUNT 10000
@@ -10,7 +13,7 @@ class TestIDNA : public ::testing::Test {
protected:
void SetUp() override {
// Intentionally Assign and not AssignLiteral
- // to simulate the usual heap case.
+ // to simulate the heap case.
mPlainASCII.Assign("example.com");
mLeadingDigitASCII.Assign("1test.example");
mUnicodeMixed.Assign("مثال.example");
@@ -20,6 +23,16 @@ class TestIDNA : public ::testing::Test {
mUnicodeRTL.Assign("الاسم.مثال");
mPunycodeRTL.Assign("xn--mgba0b1dh.xn--mgbh0fb");
// Intentionally not assigning to mEmpty
+
+ // For measuring the case inside nsStandardURL
+ mUrlPlainASCII.Assign("https://example.com/");
+ mUrlLeadingDigitASCII.Assign("https://1test.example/");
+ mUrlUnicodeMixed.Assign("https://مثال.example/");
+ mUrlPunycodeMixed.Assign("https://xn--mgbh0fb.example/");
+ mUrlUnicodeLTR.Assign("https://නම.උදාහරණ/");
+ mUrlPunycodeLTR.Assign("https://xn--r0co.xn--ozc8dl2c3bxd/");
+ mUrlUnicodeRTL.Assign("https://الاسم.مثال/");
+ mUrlPunycodeRTL.Assign("https://xn--mgba0b1dh.xn--mgbh0fb/");
}
public:
@@ -32,6 +45,14 @@ class TestIDNA : public ::testing::Test {
nsCString mUnicodeRTL;
nsCString mPunycodeRTL;
nsCString mEmpty; // Extremely suspicious measurement!
+ nsCString mUrlPlainASCII;
+ nsCString mUrlLeadingDigitASCII;
+ nsCString mUrlUnicodeMixed;
+ nsCString mUrlPunycodeMixed;
+ nsCString mUrlUnicodeLTR;
+ nsCString mUrlPunycodeLTR;
+ nsCString mUrlUnicodeRTL;
+ nsCString mUrlPunycodeRTL;
};
#define IDNA_ITERATIONS 50000
@@ -44,6 +65,17 @@ class TestIDNA : public ::testing::Test {
} \
});
+#define IDNA_URL_BENCH(name, src) \
+ MOZ_GTEST_BENCH_F(TestIDNA, name, [this] { \
+ for (int i = 0; i < IDNA_ITERATIONS; i++) { \
+ nsCOMPtr<nsIURI> dst; \
+ nsresult rv = NS_NewURI(getter_AddRefs(dst), *mozilla::BlackBox(&src), \
+ UTF_8_ENCODING); \
+ ASSERT_EQ(NS_OK, rv); \
+ mozilla::BlackBox(&dst); \
+ } \
+ });
+
IDNA_BENCH(BenchToASCIIPlainASCII, NS_DomainToASCII, mPlainASCII);
IDNA_BENCH(BenchToASCIILeadingDigitASCII, NS_DomainToASCII, mLeadingDigitASCII);
IDNA_BENCH(BenchToASCIIUnicodeMixed, NS_DomainToASCII, mUnicodeMixed);
@@ -75,3 +107,12 @@ IDNA_BENCH(BenchToUnicodePunycodeLTR, NS_DomainToUnicode, mPunycodeLTR);
IDNA_BENCH(BenchToUnicodeUnicodeRTL, NS_DomainToUnicode, mUnicodeRTL);
IDNA_BENCH(BenchToUnicodePunycodeRTL, NS_DomainToUnicode, mPunycodeRTL);
IDNA_BENCH(BenchToUnicodeEmpty, NS_DomainToUnicode, mEmpty);
+
+IDNA_URL_BENCH(BenchUrlPlainASCII, mUrlPlainASCII);
+IDNA_URL_BENCH(BenchUrlLeadingDigitASCII, mUrlLeadingDigitASCII);
+IDNA_URL_BENCH(BenchUrlUnicodeMixed, mUrlUnicodeMixed);
+IDNA_URL_BENCH(BenchUrlPunycodeMixed, mUrlPunycodeMixed);
+IDNA_URL_BENCH(BenchUrlUnicodeLTR, mUrlUnicodeLTR);
+IDNA_URL_BENCH(BenchUrlPunycodeLTR, mUrlPunycodeLTR);
+IDNA_URL_BENCH(BenchUrlUnicodeRTL, mUrlUnicodeRTL);
+IDNA_URL_BENCH(BenchUrlPunycodeRTL, mUrlPunycodeRTL);
diff --git a/netwerk/test/gtest/TestInputStreamTransport.cpp b/netwerk/test/gtest/TestInputStreamTransport.cpp
index 43df0e193a..de19f48147 100644
--- a/netwerk/test/gtest/TestInputStreamTransport.cpp
+++ b/netwerk/test/gtest/TestInputStreamTransport.cpp
@@ -29,7 +29,7 @@ void CreateStream(already_AddRefed<nsIInputStream> aSource,
ASSERT_EQ(NS_OK, rv);
nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(wrapper);
- MOZ_ASSERT(asyncStream);
+ MOZ_RELEASE_ASSERT(asyncStream);
asyncStream.forget(aStream);
}
diff --git a/netwerk/test/gtest/TestNamedPipeService.cpp b/netwerk/test/gtest/TestNamedPipeService.cpp
index b91a17a93e..ef764dde13 100644
--- a/netwerk/test/gtest/TestNamedPipeService.cpp
+++ b/netwerk/test/gtest/TestNamedPipeService.cpp
@@ -31,7 +31,7 @@ class Event {
void Set() {
MonitorAutoLock lock(mMonitor);
- MOZ_ASSERT(!mSignaled);
+ MOZ_RELEASE_ASSERT(!mSignaled);
mSignaled = true;
mMonitor.Notify();
}
diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build
index 8e0d66f4e2..a0333ecde7 100644
--- a/netwerk/test/gtest/moz.build
+++ b/netwerk/test/gtest/moz.build
@@ -23,6 +23,7 @@ UNIFIED_SOURCES += [
"TestLinkHeader.cpp",
"TestMIMEInputStream.cpp",
"TestMozURL.cpp",
+ "TestPACMan.cpp",
"TestProtocolProxyService.cpp",
"TestReadStreamToString.cpp",
"TestServerTimingHeader.cpp",
@@ -30,24 +31,15 @@ UNIFIED_SOURCES += [
"TestSSLTokensCache.cpp",
"TestStandardURL.cpp",
"TestUDPSocket.cpp",
+ "TestURIMutator.cpp",
]
if CONFIG["OS_TARGET"] == "WINNT":
UNIFIED_SOURCES += [
"TestNamedPipeService.cpp",
+ "TestNetworkLinkIdHashingWindows.cpp",
]
-# skip the test on windows10-aarch64
-if not (CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64"):
- UNIFIED_SOURCES += [
- "TestPACMan.cpp",
- "TestURIMutator.cpp",
- ]
-
-# run the test on windows only
-if CONFIG["OS_TARGET"] == "WINNT":
- UNIFIED_SOURCES += ["TestNetworkLinkIdHashingWindows.cpp"]
-
# run the test on mac only
if CONFIG["TARGET_OS"] == "OSX":
UNIFIED_SOURCES += ["TestNetworkLinkIdHashingDarwin.cpp"]