| 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/active_script_controller.h" | 8 #include "chrome/browser/extensions/active_script_controller.h" |
| 9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 // If the extension has permission, we should be able to simply wait for it | 260 // If the extension has permission, we should be able to simply wait for it |
| 261 // to execute. | 261 // to execute. |
| 262 if (requires_consent_ == DOES_NOT_REQUIRE_CONSENT) { | 262 if (requires_consent_ == DOES_NOT_REQUIRE_CONSENT) { |
| 263 inject_success_listener_->WaitUntilSatisfied(); | 263 inject_success_listener_->WaitUntilSatisfied(); |
| 264 return testing::AssertionSuccess(); | 264 return testing::AssertionSuccess(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // Otherwise, we don't have permission, and have to grant it. Ensure the | 267 // Otherwise, we don't have permission, and have to grant it. Ensure the |
| 268 // script has *not* already executed. | 268 // script has *not* already executed. |
| 269 // Currently, it's okay for content scripts to execute, because we don't | 269 if (inject_success_listener_->was_satisfied()) { |
| 270 // block them. | |
| 271 // TODO(rdevlin.cronin): Fix this. | |
| 272 if (inject_success_listener_->was_satisfied() && type_ != CONTENT_SCRIPT) { | |
| 273 return testing::AssertionFailure() << | 270 return testing::AssertionFailure() << |
| 274 name_ << "'s script ran without permission."; | 271 name_ << "'s script ran without permission."; |
| 275 } | 272 } |
| 276 | 273 |
| 277 // If we reach this point, we should always have an action. | 274 // If we reach this point, we should always have an action. |
| 278 DCHECK(action); | 275 DCHECK(action); |
| 279 | 276 |
| 280 // Grant permission by clicking on the extension action. | 277 // Grant permission by clicking on the extension action. |
| 281 location_bar_controller->OnClicked(action); | 278 location_bar_controller->OnClicked(action); |
| 282 | 279 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // inject the script. | 363 // inject the script. |
| 367 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 364 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 368 ui_test_utils::NavigateToURL( | 365 ui_test_utils::NavigateToURL( |
| 369 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); | 366 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
| 370 | 367 |
| 371 for (size_t i = 0u; i < arraysize(testers); ++i) | 368 for (size_t i = 0u; i < arraysize(testers); ++i) |
| 372 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; | 369 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; |
| 373 } | 370 } |
| 374 | 371 |
| 375 } // namespace extensions | 372 } // namespace extensions |
| OLD | NEW |