OLD | NEW |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ASSERT_EQ(id_, cracked_id); | 158 ASSERT_EQ(id_, cracked_id); |
159 | 159 |
160 // Trying to crack "/foo" should fail (because "foo" is not the one | 160 // Trying to crack "/foo" should fail (because "foo" is not the one |
161 // included in the kTestPaths). | 161 // included in the kTestPaths). |
162 virtual_path = isolated_context()->CreateVirtualPath( | 162 virtual_path = isolated_context()->CreateVirtualPath( |
163 id_, FilePath(FPL("foo"))); | 163 id_, FilePath(FPL("foo"))); |
164 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( | 164 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( |
165 virtual_path, &cracked_id, &root_path, &cracked_path)); | 165 virtual_path, &cracked_id, &root_path, &cracked_path)); |
166 } | 166 } |
167 | 167 |
| 168 TEST_F(IsolatedContextTest, Writable) { |
| 169 // By default the file system must be read-only. |
| 170 ASSERT_FALSE(isolated_context()->IsWritable(id_)); |
| 171 |
| 172 // Set writable. |
| 173 ASSERT_TRUE(isolated_context()->SetWritable(id_, true)); |
| 174 ASSERT_TRUE(isolated_context()->IsWritable(id_)); |
| 175 |
| 176 // Set non-writable. |
| 177 ASSERT_TRUE(isolated_context()->SetWritable(id_, false)); |
| 178 ASSERT_FALSE(isolated_context()->IsWritable(id_)); |
| 179 |
| 180 // Set writable again, and revoke the filesystem. |
| 181 ASSERT_TRUE(isolated_context()->SetWritable(id_, true)); |
| 182 isolated_context()->RevokeIsolatedFileSystem(id_); |
| 183 |
| 184 // IsWritable should return false for non-registered file system. |
| 185 ASSERT_FALSE(isolated_context()->IsWritable(id_)); |
| 186 // SetWritable should also return false for non-registered file system |
| 187 // (no matter what value we give). |
| 188 ASSERT_FALSE(isolated_context()->SetWritable(id_, true)); |
| 189 ASSERT_FALSE(isolated_context()->SetWritable(id_, false)); |
| 190 } |
| 191 |
168 } // namespace fileapi | 192 } // namespace fileapi |
OLD | NEW |