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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 policy_->RevokeRightsForExtension(extension.get()); | 244 policy_->RevokeRightsForExtension(extension.get()); |
245 ExpectProtectedBy(empty_set, GURL("http://explicit/")); | 245 ExpectProtectedBy(empty_set, GURL("http://explicit/")); |
246 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); | 246 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); |
247 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); | 247 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); |
248 ExpectProtectedBy(empty_set, GURL("http://bar.wildcards/")); | 248 ExpectProtectedBy(empty_set, GURL("http://bar.wildcards/")); |
249 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("http://explicit/"))); | 249 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("http://explicit/"))); |
250 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://foo.wildcards/"))); | 250 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://foo.wildcards/"))); |
251 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://bar.wildcards/"))); | 251 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://bar.wildcards/"))); |
252 } | 252 } |
253 | 253 |
254 TEST_F(ExtensionSpecialStoragePolicyTest, CanQueryDiskSize) { | |
255 const GURL kHttpUrl("http://foo"); | |
256 const GURL kExtensionUrl("chrome-extension://bar"); | |
257 scoped_refptr<Extension> regular_app(CreateRegularApp()); | |
258 scoped_refptr<Extension> protected_app(CreateProtectedApp()); | |
259 scoped_refptr<Extension> unlimited_app(CreateUnlimitedApp()); | |
260 policy_->GrantRightsForExtension(regular_app.get(), NULL); | |
261 policy_->GrantRightsForExtension(protected_app.get(), NULL); | |
262 policy_->GrantRightsForExtension(unlimited_app.get(), NULL); | |
263 | |
264 EXPECT_FALSE(policy_->CanQueryDiskSize(kHttpUrl)); | |
265 EXPECT_FALSE(policy_->CanQueryDiskSize(kExtensionUrl)); | |
266 EXPECT_TRUE(policy_->CanQueryDiskSize(regular_app->url())); | |
267 EXPECT_TRUE(policy_->CanQueryDiskSize(protected_app->url())); | |
268 EXPECT_TRUE(policy_->CanQueryDiskSize(unlimited_app->url())); | |
269 } | |
270 | |
271 TEST_F(ExtensionSpecialStoragePolicyTest, HasIsolatedStorage) { | 254 TEST_F(ExtensionSpecialStoragePolicyTest, HasIsolatedStorage) { |
272 const GURL kHttpUrl("http://foo"); | 255 const GURL kHttpUrl("http://foo"); |
273 const GURL kExtensionUrl("chrome-extension://bar"); | 256 const GURL kExtensionUrl("chrome-extension://bar"); |
274 scoped_refptr<Extension> app(CreateRegularApp()); | 257 scoped_refptr<Extension> app(CreateRegularApp()); |
275 policy_->GrantRightsForExtension(app.get(), NULL); | 258 policy_->GrantRightsForExtension(app.get(), NULL); |
276 | 259 |
277 EXPECT_FALSE(policy_->HasIsolatedStorage(kHttpUrl)); | 260 EXPECT_FALSE(policy_->HasIsolatedStorage(kHttpUrl)); |
278 EXPECT_FALSE(policy_->HasIsolatedStorage(kExtensionUrl)); | 261 EXPECT_FALSE(policy_->HasIsolatedStorage(kExtensionUrl)); |
279 EXPECT_TRUE(policy_->HasIsolatedStorage(app->url())); | 262 EXPECT_TRUE(policy_->HasIsolatedStorage(app->url())); |
280 } | 263 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 EXPECT_TRUE(observer.IsCompleted()); | 391 EXPECT_TRUE(observer.IsCompleted()); |
409 } | 392 } |
410 | 393 |
411 observer.ExpectClear(); | 394 observer.ExpectClear(); |
412 policy_->RevokeRightsForAllExtensions(); | 395 policy_->RevokeRightsForAllExtensions(); |
413 base::RunLoop().RunUntilIdle(); | 396 base::RunLoop().RunUntilIdle(); |
414 EXPECT_TRUE(observer.IsCompleted()); | 397 EXPECT_TRUE(observer.IsCompleted()); |
415 | 398 |
416 policy_->RemoveObserver(&observer); | 399 policy_->RemoveObserver(&observer); |
417 } | 400 } |
OLD | NEW |