| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/common/extensions/extension_constants.h" | 6 #include "chrome/common/extensions/extension_constants.h" |
| 7 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" | 7 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
| 8 #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h" | 8 #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h" |
| 9 #include "content/public/test/mock_render_process_host.h" | 9 #include "content/public/test/mock_render_process_host.h" |
| 10 #include "content/public/test/mock_render_thread.h" | 10 #include "content/public/test/mock_render_thread.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 // Tests that CanAccessPage returns false for the any process | 62 // Tests that CanAccessPage returns false for the any process |
| 63 // which hosts the webstore. | 63 // which hosts the webstore. |
| 64 TEST_F(RendererPermissionsPolicyDelegateTest, CannotScriptWebstore) { | 64 TEST_F(RendererPermissionsPolicyDelegateTest, CannotScriptWebstore) { |
| 65 GURL kAnyUrl("http://example.com/"); | 65 GURL kAnyUrl("http://example.com/"); |
| 66 scoped_refptr<const Extension> extension(CreateTestExtension("a")); | 66 scoped_refptr<const Extension> extension(CreateTestExtension("a")); |
| 67 std::string error; | 67 std::string error; |
| 68 | 68 |
| 69 EXPECT_TRUE(extension->permissions_data()->CanAccessPage( | 69 EXPECT_TRUE(extension->permissions_data()->CanAccessPage( |
| 70 extension.get(), kAnyUrl, kAnyUrl, -1, -1, &error)) | 70 extension.get(), kAnyUrl, -1, -1, &error)) << error; |
| 71 << error; | |
| 72 | 71 |
| 73 // Pretend we are in the webstore process. We should not be able to execute | 72 // Pretend we are in the webstore process. We should not be able to execute |
| 74 // script. | 73 // script. |
| 75 scoped_refptr<const Extension> webstore_extension( | 74 scoped_refptr<const Extension> webstore_extension( |
| 76 CreateTestExtension(extensions::kWebStoreAppId)); | 75 CreateTestExtension(extensions::kWebStoreAppId)); |
| 77 extension_dispatcher_->OnLoadedInternal(webstore_extension); | 76 extension_dispatcher_->OnLoadedInternal(webstore_extension); |
| 78 extension_dispatcher_->OnActivateExtension(extensions::kWebStoreAppId); | 77 extension_dispatcher_->OnActivateExtension(extensions::kWebStoreAppId); |
| 79 EXPECT_FALSE(extension->permissions_data()->CanAccessPage( | 78 EXPECT_FALSE(extension->permissions_data()->CanAccessPage( |
| 80 extension.get(), kAnyUrl, kAnyUrl, -1, -1, &error)) | 79 extension.get(), kAnyUrl, -1, -1, &error)) |
| 81 << error; | 80 << error; |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace extensions | 83 } // namespace extensions |
| OLD | NEW |