Index: webkit/database/database_util_unittest.cc |
diff --git a/webkit/database/database_util_unittest.cc b/webkit/database/database_util_unittest.cc |
index 18c701402c5e3a33fb8722a8f349e3804ce4a187..aa9d007ac9494f3a388bd6195936a204221c6173 100644 |
--- a/webkit/database/database_util_unittest.cc |
+++ b/webkit/database/database_util_unittest.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/string_piece.h" |
#include "base/utf_string_conversions.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "webkit/database/database_util.h" |
@@ -31,6 +32,12 @@ static GURL ToAndFromOriginIdentifier(const GURL origin_url) { |
return DatabaseUtil::GetOriginFromIdentifier(id); |
} |
+static void TestValidOriginIdentifier(bool expected_result, |
+ const base::StringPiece id) { |
+ EXPECT_EQ(expected_result, |
+ DatabaseUtil::IsValidOriginIdentifier(ASCIIToUTF16(id))); |
+} |
+ |
namespace webkit_database { |
// Test DatabaseUtil::CrackVfsFilePath on various inputs. |
@@ -54,4 +61,13 @@ TEST(DatabaseUtilTest, OriginIdentifiers) { |
EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin)); |
} |
+TEST(DatabaseUtilTest, IsValidOriginIdentifier) { |
+ TestValidOriginIdentifier(true, "http_bar_0"); |
+ TestValidOriginIdentifier(true, ""); |
+ TestValidOriginIdentifier(false, "bad..id"); |
+ TestValidOriginIdentifier(false, "bad/id"); |
+ TestValidOriginIdentifier(false, "bad\\id"); |
+ TestValidOriginIdentifier(false, base::StringPiece("bad\0id", 6)); |
+} |
+ |
} // namespace webkit_database |