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

Side by Side Diff: webkit/fileapi/isolated_context_unittest.cc

Issue 10837217: Add RevokeFileSystem back to IsolatedContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/isolated_context.h" 5 #include "webkit/fileapi/isolated_context.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 kFileSystemTypeIsolated, FilePath(DRIVE FPL("/foo")), NULL); 117 kFileSystemTypeIsolated, FilePath(DRIVE FPL("/foo")), NULL);
118 118
119 // Make sure the GetDraggedFileInfo returns false for both ones. 119 // Make sure the GetDraggedFileInfo returns false for both ones.
120 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id2, &toplevels)); 120 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id2, &toplevels));
121 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels)); 121 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels));
122 122
123 // Make sure the GetRegisteredPath returns true only for the new one. 123 // Make sure the GetRegisteredPath returns true only for the new one.
124 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); 124 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path));
125 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); 125 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
126 126
127 // Try registering two more file systems for the same path as id2. 127 // Try registering three more file systems for the same path as id2.
128 std::string id3 = isolated_context()->RegisterFileSystemForPath( 128 std::string id3 = isolated_context()->RegisterFileSystemForPath(
129 kFileSystemTypeIsolated, path, NULL); 129 kFileSystemTypeIsolated, path, NULL);
130 std::string id4 = isolated_context()->RegisterFileSystemForPath( 130 std::string id4 = isolated_context()->RegisterFileSystemForPath(
131 kFileSystemTypeIsolated, path, NULL); 131 kFileSystemTypeIsolated, path, NULL);
132 std::string id5 = isolated_context()->RegisterFileSystemForPath(
133 kFileSystemTypeIsolated, path, NULL);
132 134
133 // Remove file system for id4. 135 // Remove file system for id4.
134 isolated_context()->AddReference(id4); 136 isolated_context()->AddReference(id4);
135 isolated_context()->RemoveReference(id4); 137 isolated_context()->RemoveReference(id4);
136 138
137 // Only id4 should become invalid now. 139 // Only id4 should become invalid now.
138 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); 140 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
139 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path)); 141 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path));
140 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); 142 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
143 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id5, &path));
144
145 // Revoke file system id5, after adding multiple references.
146 isolated_context()->AddReference(id5);
147 isolated_context()->AddReference(id5);
148 isolated_context()->AddReference(id5);
149 isolated_context()->RevokeFileSystem(id5);
150
151 // No matter how many references we add id5 must be invalid now.
152 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
153 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path));
154 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
155 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id5, &path));
141 156
142 // Revoke the file systems by path. 157 // Revoke the file systems by path.
143 isolated_context()->RevokeFileSystemByPath(path); 158 isolated_context()->RevokeFileSystemByPath(path);
144 159
145 // Now all the file systems associated to the path must be invalid. 160 // Now all the file systems associated to the path must be invalid.
146 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id2, &path)); 161 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id2, &path));
147 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id3, &path)); 162 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id3, &path));
148 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); 163 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
164 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id5, &path));
149 } 165 }
150 166
151 TEST_F(IsolatedContextTest, CrackWithRelativePaths) { 167 TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
152 const struct { 168 const struct {
153 FilePath::StringType path; 169 FilePath::StringType path;
154 bool valid; 170 bool valid;
155 } relatives[] = { 171 } relatives[] = {
156 { FPL("foo"), true }, 172 { FPL("foo"), true },
157 { FPL("foo/bar"), true }, 173 { FPL("foo/bar"), true },
158 { FPL(".."), false }, 174 { FPL(".."), false },
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 223
208 // Trying to crack "/foo" should fail (because "foo" is not the one 224 // Trying to crack "/foo" should fail (because "foo" is not the one
209 // included in the kTestPaths). 225 // included in the kTestPaths).
210 virtual_path = isolated_context()->CreateVirtualRootPath( 226 virtual_path = isolated_context()->CreateVirtualRootPath(
211 id_).AppendASCII("foo"); 227 id_).AppendASCII("foo");
212 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( 228 ASSERT_FALSE(isolated_context()->CrackIsolatedPath(
213 virtual_path, &cracked_id, NULL, &cracked_path)); 229 virtual_path, &cracked_id, NULL, &cracked_path));
214 } 230 }
215 231
216 } // namespace fileapi 232 } // namespace fileapi
OLDNEW
« webkit/fileapi/isolated_context.cc ('K') | « webkit/fileapi/isolated_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698