diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /netwerk/test/gtest | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.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.cpp | 64 | ||||
-rw-r--r-- | netwerk/test/gtest/moz.build | 6 |
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") |