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

Unified Diff: webkit/fileapi/isolated_context_unittest.cc

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 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 | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/isolated_context_unittest.cc
diff --git a/webkit/fileapi/isolated_context_unittest.cc b/webkit/fileapi/isolated_context_unittest.cc
index bf36df91886856386c6e26d624e20cf96de290e0..4cb7a84d2e426115988db160e6fe132d8382dc9f 100644
--- a/webkit/fileapi/isolated_context_unittest.cc
+++ b/webkit/fileapi/isolated_context_unittest.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/isolated_context.h"
#define FPL(x) FILE_PATH_LITERAL(x)
@@ -189,7 +190,7 @@ TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
.AppendASCII(names_[i]).Append(relatives[j].path);
std::string cracked_id;
FilePath cracked_path;
- FileSystemType cracked_type;
+ FileSystemType cracked_type;
if (!relatives[j].valid) {
ASSERT_FALSE(isolated_context()->CrackVirtualPath(
virtual_path, &cracked_id, &cracked_type, &cracked_path));
@@ -206,6 +207,51 @@ TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
}
}
+TEST_F(IsolatedContextTest, CrackURLWithRelativePaths) {
+ const struct {
+ FilePath::StringType path;
+ bool valid;
+ } relatives[] = {
+ { FPL("foo"), true },
+ { FPL("foo/bar"), true },
+ { FPL(".."), false },
+ { FPL("foo/.."), false },
+ { FPL("foo/../bar"), false },
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+# define SHOULD_FAIL_WITH_WIN_SEPARATORS false
+#else
+# define SHOULD_FAIL_WITH_WIN_SEPARATORS true
+#endif
+ { FPL("foo\\..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
+ { FPL("foo/..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
+ };
+
+ for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
+ for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) {
+ SCOPED_TRACE(testing::Message() << "Testing "
+ << kTestPaths[i].value() << " " << relatives[j].path);
+ FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
+ .AppendASCII(names_[i]).Append(relatives[j].path);
+
+ FileSystemURL cracked = isolated_context()->CreateCrackedFileSystemURL(
+ GURL("http://chromium.org"), kFileSystemTypeIsolated, virtual_path);
+
+ ASSERT_EQ(relatives[j].valid, cracked.is_valid());
+
+ if (!relatives[j].valid)
+ continue;
+ ASSERT_EQ(GURL("http://chromium.org"), cracked.origin());
+ ASSERT_EQ(kTestPaths[i].Append(relatives[j].path)
+ .NormalizePathSeparators().value(),
+ cracked.path().value());
+ ASSERT_EQ(virtual_path.NormalizePathSeparators(), cracked.virtual_path());
+ ASSERT_EQ(id_, cracked.filesystem_id());
+ ASSERT_EQ(kFileSystemTypeDragged, cracked.type());
+ ASSERT_EQ(kFileSystemTypeIsolated, cracked.mount_type());
+ }
+ }
+}
+
TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
std::string cracked_id;
FilePath cracked_path;
@@ -227,4 +273,32 @@ TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
virtual_path, &cracked_id, NULL, &cracked_path));
}
+TEST_F(IsolatedContextTest, CanHandleURL) {
+ const GURL test_origin("http://chromium.org");
+ const FilePath test_path(FPL("/mount"));
+
+ // Should handle isolated file system.
+ EXPECT_TRUE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeIsolated));
+
+ // Shouldn't handle the rest.
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeExternal));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeTemporary));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypePersistent));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeTest));
+ // Not even if it's isolated subtype.
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeNativeLocal));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeDragged));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeNativeMedia));
+ EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
+ fileapi::kFileSystemTypeDeviceMedia));
+}
+
} // namespace fileapi
« no previous file with comments | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698