Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: content/common/database_identifier_unittest.cc

Issue 1753403002: Move IsValidOriginIdentifier into appropriate header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/database_message_filter.cc ('k') | storage/browser/database/database_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/database_identifier_unittest.cc
diff --git a/content/common/database_identifier_unittest.cc b/content/common/database_identifier_unittest.cc
index f866b7639ef1a722ae2f15f460b4e0b9ced6903a..2e704d89773cc89c66e601fcfd0e06069e7c239e 100644
--- a/content/common/database_identifier_unittest.cc
+++ b/content/common/database_identifier_unittest.cc
@@ -245,5 +245,33 @@ TEST(DatabaseIdentifierTest, ExtractOriginDataFromIdentifier) {
}
}
+static GURL ToAndFromOriginIdentifier(const GURL origin_url) {
+ std::string id = storage::GetIdentifierFromOrigin(origin_url);
+ return storage::GetOriginFromIdentifier(id);
+}
+
+static void TestValidOriginIdentifier(bool expected_result,
+ const std::string& id) {
+ EXPECT_EQ(expected_result,
+ storage::IsValidOriginIdentifier(id));
+}
+
+TEST(DatabaseIdentifierTest, OriginIdentifiers) {
jsbell 2016/03/02 20:29:09 These are probably redundant with above cases. Lef
+ const GURL kFileOrigin(GURL("file:///").GetOrigin());
+ const GURL kHttpOrigin(GURL("http://bar/").GetOrigin());
+ EXPECT_EQ(kFileOrigin, ToAndFromOriginIdentifier(kFileOrigin));
+ EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin));
+}
+
+TEST(DatabaseIdentifierTest, IsValidOriginIdentifier) {
+ TestValidOriginIdentifier(true, "http_bar_0");
+ TestValidOriginIdentifier(false, "");
+ TestValidOriginIdentifier(false, "bad..id");
+ TestValidOriginIdentifier(false, "bad/id");
+ TestValidOriginIdentifier(false, "bad\\id");
+ TestValidOriginIdentifier(false, "http_bad:0_2");
+ TestValidOriginIdentifier(false, std::string("bad\0id", 6));
+}
+
} // namespace
} // namespace content
« no previous file with comments | « content/browser/renderer_host/database_message_filter.cc ('k') | storage/browser/database/database_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698