OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/macros.h" | 5 #include "base/macros.h" |
6 #include "chrome/browser/extensions/active_script_controller.h" | 6 #include "chrome/browser/extensions/active_script_controller.h" |
7 #include "chrome/browser/extensions/extension_action.h" | 7 #include "chrome/browser/extensions/extension_action.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
10 #include "chrome/browser/extensions/location_bar_controller.h" | 10 #include "chrome/browser/extensions/location_bar_controller.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // If the extension has permission, we should be able to simply wait for it | 143 // If the extension has permission, we should be able to simply wait for it |
144 // to execute. | 144 // to execute. |
145 if (!requires_consent_) { | 145 if (!requires_consent_) { |
146 inject_success_listener_->WaitUntilSatisfied(); | 146 inject_success_listener_->WaitUntilSatisfied(); |
147 return testing::AssertionSuccess(); | 147 return testing::AssertionSuccess(); |
148 } | 148 } |
149 | 149 |
150 // Otherwise, we don't have permission, and have to grant it. Ensure the | 150 // Otherwise, we don't have permission, and have to grant it. Ensure the |
151 // script has *not* already executed. | 151 // script has *not* already executed. |
152 // Currently, it's okay for content scripts to execute, because we don't | 152 // Currently, it's okay for content scripts to execute, because we don't |
153 // block them. | 153 // block them. |
not at google - send to devlin
2014/05/15 00:31:54
comment needs updating?
Devlin
2014/05/20 16:48:09
Whoops, thanks.
| |
154 // TODO(rdevlin.cronin): Fix this. | 154 if (inject_success_listener_->was_satisfied()) { |
155 if (inject_success_listener_->was_satisfied() && type_ != CONTENT_SCRIPT) { | |
156 return testing::AssertionFailure() << | 155 return testing::AssertionFailure() << |
157 name_ << "'s script ran without permission."; | 156 name_ << "'s script ran without permission."; |
158 } | 157 } |
159 | 158 |
160 ExtensionAction* action = controller->GetActionForExtension(extension_); | 159 ExtensionAction* action = controller->GetActionForExtension(extension_); |
161 // We've already verified this exists, so just a sanity check. | 160 // We've already verified this exists, so just a sanity check. |
162 DCHECK(action); | 161 DCHECK(action); |
163 | 162 |
164 // Grant permission by clicking on the extension action. | 163 // Grant permission by clicking on the extension action. |
165 location_bar_controller->OnClicked(action); | 164 location_bar_controller->OnClicked(action); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 // inject the script. | 223 // inject the script. |
225 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 224 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
226 ui_test_utils::NavigateToURL( | 225 ui_test_utils::NavigateToURL( |
227 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); | 226 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
228 | 227 |
229 for (size_t i = 0u; i < arraysize(testers); ++i) | 228 for (size_t i = 0u; i < arraysize(testers); ++i) |
230 EXPECT_TRUE(testers[i].Verify(browser())) << kExtensionNames[i]; | 229 EXPECT_TRUE(testers[i].Verify(browser())) << kExtensionNames[i]; |
231 } | 230 } |
232 | 231 |
233 } // namespace extensions | 232 } // namespace extensions |
OLD | NEW |