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 |
254 TEST_F(ExtensionSpecialStoragePolicyTest, HasIsolatedStorage) { | 271 TEST_F(ExtensionSpecialStoragePolicyTest, HasIsolatedStorage) { |
255 const GURL kHttpUrl("http://foo"); | 272 const GURL kHttpUrl("http://foo"); |
256 const GURL kExtensionUrl("chrome-extension://bar"); | 273 const GURL kExtensionUrl("chrome-extension://bar"); |
257 scoped_refptr<Extension> app(CreateRegularApp()); | 274 scoped_refptr<Extension> app(CreateRegularApp()); |
258 policy_->GrantRightsForExtension(app.get(), NULL); | 275 policy_->GrantRightsForExtension(app.get(), NULL); |
259 | 276 |
260 EXPECT_FALSE(policy_->HasIsolatedStorage(kHttpUrl)); | 277 EXPECT_FALSE(policy_->HasIsolatedStorage(kHttpUrl)); |
261 EXPECT_FALSE(policy_->HasIsolatedStorage(kExtensionUrl)); | 278 EXPECT_FALSE(policy_->HasIsolatedStorage(kExtensionUrl)); |
262 EXPECT_TRUE(policy_->HasIsolatedStorage(app->url())); | 279 EXPECT_TRUE(policy_->HasIsolatedStorage(app->url())); |
263 } | 280 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 EXPECT_TRUE(observer.IsCompleted()); | 408 EXPECT_TRUE(observer.IsCompleted()); |
392 } | 409 } |
393 | 410 |
394 observer.ExpectClear(); | 411 observer.ExpectClear(); |
395 policy_->RevokeRightsForAllExtensions(); | 412 policy_->RevokeRightsForAllExtensions(); |
396 base::RunLoop().RunUntilIdle(); | 413 base::RunLoop().RunUntilIdle(); |
397 EXPECT_TRUE(observer.IsCompleted()); | 414 EXPECT_TRUE(observer.IsCompleted()); |
398 | 415 |
399 policy_->RemoveObserver(&observer); | 416 policy_->RemoveObserver(&observer); |
400 } | 417 } |
OLD | NEW |