summaryrefslogtreecommitdiffstats
path: root/netwerk/test/gtest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /netwerk/test/gtest
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/gtest')
-rw-r--r--netwerk/test/gtest/TestCacheControlParser.cpp64
-rw-r--r--netwerk/test/gtest/moz.build6
2 files changed, 68 insertions, 2 deletions
diff --git a/netwerk/test/gtest/TestCacheControlParser.cpp b/netwerk/test/gtest/TestCacheControlParser.cpp
new file mode 100644
index 0000000000..df1cd9ec73
--- /dev/null
+++ b/netwerk/test/gtest/TestCacheControlParser.cpp
@@ -0,0 +1,64 @@
+#include "gtest/gtest.h"
+
+#include "CacheControlParser.h"
+
+using namespace mozilla;
+using namespace mozilla::net;
+
+TEST(TestCacheControlParser, NegativeMaxAge)
+{
+ CacheControlParser cc(
+ "no-store,no-cache,max-age=-3600,max-stale=7,private"_ns);
+ ASSERT_TRUE(cc.NoStore());
+ ASSERT_TRUE(cc.NoCache());
+ uint32_t max_age{2};
+ ASSERT_FALSE(cc.MaxAge(&max_age));
+ ASSERT_EQ(max_age, 0U);
+ uint32_t max_stale;
+ ASSERT_TRUE(cc.MaxStale(&max_stale));
+ ASSERT_EQ(max_stale, 7U);
+ ASSERT_TRUE(cc.Private());
+}
+
+TEST(TestCacheControlParser, EmptyMaxAge)
+{
+ CacheControlParser cc("no-store,no-cache,max-age,max-stale=77,private"_ns);
+ ASSERT_TRUE(cc.NoStore());
+ ASSERT_TRUE(cc.NoCache());
+ uint32_t max_age{5};
+ ASSERT_FALSE(cc.MaxAge(&max_age));
+ ASSERT_EQ(max_age, 0U);
+ uint32_t max_stale;
+ ASSERT_TRUE(cc.MaxStale(&max_stale));
+ ASSERT_EQ(max_stale, 77U);
+ ASSERT_TRUE(cc.Private());
+}
+
+TEST(TestCacheControlParser, NegaTiveMaxStale)
+{
+ CacheControlParser cc(
+ "no-store,no-cache,max-age=3600,max-stale=-222,private"_ns);
+ ASSERT_TRUE(cc.NoStore());
+ ASSERT_TRUE(cc.NoCache());
+ uint32_t max_age;
+ ASSERT_TRUE(cc.MaxAge(&max_age));
+ ASSERT_EQ(max_age, 3600U);
+ uint32_t max_stale;
+ ASSERT_TRUE(cc.MaxStale(&max_stale));
+ ASSERT_EQ(max_stale, PR_UINT32_MAX);
+ ASSERT_TRUE(cc.Private());
+}
+
+TEST(TestCacheControlParser, EmptyMaxStale)
+{
+ CacheControlParser cc("no-store,no-cache,max-age=3600,max-stale,private"_ns);
+ ASSERT_TRUE(cc.NoStore());
+ ASSERT_TRUE(cc.NoCache());
+ uint32_t max_age;
+ ASSERT_TRUE(cc.MaxAge(&max_age));
+ ASSERT_EQ(max_age, 3600U);
+ uint32_t max_stale;
+ ASSERT_TRUE(cc.MaxStale(&max_stale));
+ ASSERT_EQ(max_stale, PR_UINT32_MAX);
+ ASSERT_TRUE(cc.Private());
+}
diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build
index b6d82b41db..571c908707 100644
--- a/netwerk/test/gtest/moz.build
+++ b/netwerk/test/gtest/moz.build
@@ -8,6 +8,7 @@ UNIFIED_SOURCES += [
"TestBase64Stream.cpp",
"TestBind.cpp",
"TestBufferedInputStream.cpp",
+ "TestCacheControlParser.cpp",
"TestCommon.cpp",
"TestCookie.cpp",
"TestDNSPacket.cpp",
@@ -47,7 +48,7 @@ if CONFIG["OS_TARGET"] == "WINNT":
UNIFIED_SOURCES += ["TestNetworkLinkIdHashingWindows.cpp"]
# run the test on mac only
-if CONFIG["OS_TARGET"] == "Darwin":
+if CONFIG["TARGET_OS"] == "OSX":
UNIFIED_SOURCES += ["TestNetworkLinkIdHashingDarwin.cpp"]
TEST_HARNESS_FILES.gtest += [
@@ -61,6 +62,7 @@ USE_LIBS += [
LOCAL_INCLUDES += [
"/netwerk/base",
"/netwerk/cookie",
+ "/netwerk/protocol/http",
"/toolkit/components/jsoncpp/include",
"/xpcom/tests/gtest",
]
@@ -70,7 +72,7 @@ if CONFIG["OS_TARGET"] == "WINNT":
LOCAL_INCLUDES += ["/netwerk/system/win32"]
# mac includes only
-if CONFIG["OS_TARGET"] == "Darwin":
+if CONFIG["TARGET_OS"] == "OSX":
LOCAL_INCLUDES += ["/netwerk/system/mac"]
include("/ipc/chromium/chromium-config.mozbuild")