summaryrefslogtreecommitdiffstats
path: root/dom/quota/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 /dom/quota/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 'dom/quota/test/gtest')
-rw-r--r--dom/quota/test/gtest/TestScopedLogExtraInfo.cpp31
-rw-r--r--dom/quota/test/gtest/TestStorageOriginAttributes.cpp75
2 files changed, 98 insertions, 8 deletions
diff --git a/dom/quota/test/gtest/TestScopedLogExtraInfo.cpp b/dom/quota/test/gtest/TestScopedLogExtraInfo.cpp
index 00a3393844..395246c1fb 100644
--- a/dom/quota/test/gtest/TestScopedLogExtraInfo.cpp
+++ b/dom/quota/test/gtest/TestScopedLogExtraInfo.cpp
@@ -16,19 +16,23 @@ TEST(DOM_Quota_ScopedLogExtraInfo, AddAndRemove)
{
const auto extraInfo =
- ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQuery, text};
+ ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQueryTainted, text};
#ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
const auto& extraInfoMap = ScopedLogExtraInfo::GetExtraInfoMap();
- EXPECT_EQ(text, *extraInfoMap.at(ScopedLogExtraInfo::kTagQuery));
+ const auto& queryValueTainted =
+ *extraInfoMap.at(ScopedLogExtraInfo::kTagQueryTainted);
+
+ EXPECT_EQ(text, MOZ_NO_VALIDATE(queryValueTainted,
+ "It's ok to use query value in tests."));
#endif
}
#ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
const auto& extraInfoMap = ScopedLogExtraInfo::GetExtraInfoMap();
- EXPECT_EQ(0u, extraInfoMap.count(ScopedLogExtraInfo::kTagQuery));
+ EXPECT_EQ(0u, extraInfoMap.count(ScopedLogExtraInfo::kTagQueryTainted));
#endif
}
@@ -39,27 +43,38 @@ TEST(DOM_Quota_ScopedLogExtraInfo, Nested)
{
const auto extraInfo =
- ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQuery, text};
+ ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQueryTainted, text};
{
const auto extraInfo =
- ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQuery, nestedText};
+ ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQueryTainted, nestedText};
#ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
const auto& extraInfoMap = ScopedLogExtraInfo::GetExtraInfoMap();
- EXPECT_EQ(nestedText, *extraInfoMap.at(ScopedLogExtraInfo::kTagQuery));
+
+ const auto& queryValueTainted =
+ *extraInfoMap.at(ScopedLogExtraInfo::kTagQueryTainted);
+
+ EXPECT_EQ(nestedText,
+ MOZ_NO_VALIDATE(queryValueTainted,
+ "It's ok to use query value in tests."));
#endif
}
#ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
const auto& extraInfoMap = ScopedLogExtraInfo::GetExtraInfoMap();
- EXPECT_EQ(text, *extraInfoMap.at(ScopedLogExtraInfo::kTagQuery));
+
+ const auto& queryValueTainted =
+ *extraInfoMap.at(ScopedLogExtraInfo::kTagQueryTainted);
+
+ EXPECT_EQ(text, MOZ_NO_VALIDATE(queryValueTainted,
+ "It's ok to use query value in tests."));
#endif
}
#ifdef QM_SCOPED_LOG_EXTRA_INFO_ENABLED
const auto& extraInfoMap = ScopedLogExtraInfo::GetExtraInfoMap();
- EXPECT_EQ(0u, extraInfoMap.count(ScopedLogExtraInfo::kTagQuery));
+ EXPECT_EQ(0u, extraInfoMap.count(ScopedLogExtraInfo::kTagQueryTainted));
#endif
}
diff --git a/dom/quota/test/gtest/TestStorageOriginAttributes.cpp b/dom/quota/test/gtest/TestStorageOriginAttributes.cpp
index 4529e1d53b..f7a8387305 100644
--- a/dom/quota/test/gtest/TestStorageOriginAttributes.cpp
+++ b/dom/quota/test/gtest/TestStorageOriginAttributes.cpp
@@ -9,6 +9,33 @@
namespace mozilla::dom::quota::test {
+TEST(DOM_Quota_StorageOriginAttributes, Constructor_Default)
+{
+ {
+ StorageOriginAttributes originAttributes;
+
+ ASSERT_FALSE(originAttributes.InIsolatedMozBrowser());
+ ASSERT_EQ(originAttributes.UserContextId(), 0u);
+ }
+}
+
+TEST(DOM_Quota_StorageOriginAttributes, Constructor_InIsolatedMozbrowser)
+{
+ {
+ StorageOriginAttributes originAttributes(/* aInIsolatedMozBrowser */ false);
+
+ ASSERT_FALSE(originAttributes.InIsolatedMozBrowser());
+ ASSERT_EQ(originAttributes.UserContextId(), 0u);
+ }
+
+ {
+ StorageOriginAttributes originAttributes(/* aInIsolatedMozBrowser */ true);
+
+ ASSERT_TRUE(originAttributes.InIsolatedMozBrowser());
+ ASSERT_EQ(originAttributes.UserContextId(), 0u);
+ }
+}
+
TEST(DOM_Quota_StorageOriginAttributes, PopulateFromOrigin_NoOriginAttributes)
{
{
@@ -162,4 +189,52 @@ TEST(DOM_Quota_StorageOriginAttributes, PopulateFromOrigin_Mixed_Invalid)
}
}
+TEST(DOM_Quota_StorageOriginAttributes, CreateSuffix_NoOriginAttributes)
+{
+ {
+ StorageOriginAttributes originAttributes;
+ nsCString suffix;
+ originAttributes.CreateSuffix(suffix);
+
+ ASSERT_TRUE(suffix.IsEmpty());
+ }
+}
+
+TEST(DOM_Quota_StorageOriginAttributes, CreateSuffix_InIsolatedMozbrowser)
+{
+ {
+ StorageOriginAttributes originAttributes;
+ originAttributes.SetInIsolatedMozBrowser(true);
+ nsCString suffix;
+ originAttributes.CreateSuffix(suffix);
+
+ ASSERT_TRUE(suffix.Equals("^inBrowser=1"_ns));
+ }
+}
+
+TEST(DOM_Quota_StorageOriginAttributes, CreateSuffix_UserContextId)
+{
+ {
+ StorageOriginAttributes originAttributes;
+ originAttributes.SetUserContextId(42);
+ nsCString suffix;
+ originAttributes.CreateSuffix(suffix);
+
+ ASSERT_TRUE(suffix.Equals("^userContextId=42"_ns));
+ }
+}
+
+TEST(DOM_Quota_StorageOriginAttributes, CreateSuffix_Mixed)
+{
+ {
+ StorageOriginAttributes originAttributes;
+ originAttributes.SetInIsolatedMozBrowser(true);
+ originAttributes.SetUserContextId(42);
+ nsCString suffix;
+ originAttributes.CreateSuffix(suffix);
+
+ ASSERT_TRUE(suffix.Equals("^inBrowser=1&userContextId=42"_ns));
+ }
+}
+
} // namespace mozilla::dom::quota::test