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

Side by Side Diff: chrome/renderer/extensions/renderer_permissions_policy_delegate_unittest.cc

Issue 1150683007: [Extensions] Use document url (not top url) for tab-specific permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698