| Index: chrome/browser/extensions/active_script_controller_unittest.cc
|
| diff --git a/chrome/browser/extensions/active_script_controller_unittest.cc b/chrome/browser/extensions/active_script_controller_unittest.cc
|
| index 010ad02b1fa119a83b07782e9f06ab24f65d3319..a2a95739d12fdd90e521509aae4ca85dcdd0bde6 100644
|
| --- a/chrome/browser/extensions/active_script_controller_unittest.cc
|
| +++ b/chrome/browser/extensions/active_script_controller_unittest.cc
|
| @@ -164,11 +164,9 @@ void ActiveScriptControllerUnitTest::SetUp() {
|
|
|
| TabHelper::CreateForWebContents(web_contents());
|
| TabHelper* tab_helper = TabHelper::FromWebContents(web_contents());
|
| - // None of these should ever be NULL.
|
| + // These should never be NULL.
|
| DCHECK(tab_helper);
|
| - DCHECK(tab_helper->location_bar_controller());
|
| - active_script_controller_ =
|
| - tab_helper->location_bar_controller()->active_script_controller();
|
| + active_script_controller_ = tab_helper->active_script_controller();
|
| DCHECK(active_script_controller_);
|
| }
|
|
|
| @@ -182,22 +180,23 @@ TEST_F(ActiveScriptControllerUnitTest, RequestPermissionAndExecute) {
|
|
|
| // Ensure that there aren't any executions pending.
|
| ASSERT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
| - ASSERT_FALSE(controller()->GetActionForExtension(extension));
|
| + ASSERT_FALSE(controller()->WantsToRun(extension));
|
|
|
| // Since the extension requests all_hosts, we should require user consent.
|
| EXPECT_TRUE(RequiresUserConsent(extension));
|
|
|
| - // Request an injection. There should be an action visible, but no executions.
|
| + // Request an injection. The extension should want to run, but should not have
|
| + // executed.
|
| RequestInjection(extension);
|
| - EXPECT_TRUE(controller()->GetActionForExtension(extension));
|
| + EXPECT_TRUE(controller()->WantsToRun(extension));
|
| EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| // Click to accept the extension executing.
|
| controller()->OnClicked(extension);
|
|
|
| - // The extension should execute, and the action should go away.
|
| + // The extension should execute, and the extension shouldn't want to run.
|
| EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
|
|
| // Since we already executed on the given page, we shouldn't need permission
|
| // for a second time.
|
| @@ -220,7 +219,7 @@ TEST_F(ActiveScriptControllerUnitTest, RequestPermissionAndExecute) {
|
| RequestInjection(extension);
|
| controller()->OnClicked(extension);
|
| EXPECT_EQ(2u, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
|
|
| // Navigating to another site should also clear the permissions.
|
| NavigateAndCommit(GURL("https://www.foo.com"));
|
| @@ -237,15 +236,15 @@ TEST_F(ActiveScriptControllerUnitTest, PendingInjectionsRemovedAtNavigation) {
|
|
|
| ASSERT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| - // Request an injection. There should be an action visible, but no executions.
|
| + // Request an injection. The extension should want to run, but not execute.
|
| RequestInjection(extension);
|
| - EXPECT_TRUE(controller()->GetActionForExtension(extension));
|
| + EXPECT_TRUE(controller()->WantsToRun(extension));
|
| EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| // Reload. This should remove the pending injection, and we should not
|
| // execute anything.
|
| Reload();
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
| EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| // Request and accept a new injection.
|
| @@ -255,7 +254,7 @@ TEST_F(ActiveScriptControllerUnitTest, PendingInjectionsRemovedAtNavigation) {
|
| // The extension should only have executed once, even though a grand total
|
| // of two executions were requested.
|
| EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
| }
|
|
|
| // Test that queueing multiple pending injections, and then accepting, triggers
|
| @@ -278,7 +277,7 @@ TEST_F(ActiveScriptControllerUnitTest, MultiplePendingInjection) {
|
|
|
| // All pending injections should have executed.
|
| EXPECT_EQ(kNumInjections, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
| }
|
|
|
| TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsUseActiveTabPermissions) {
|
| @@ -315,7 +314,7 @@ TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsUseActiveTabPermissions) {
|
| EXPECT_TRUE(RequiresUserConsent(extension));
|
|
|
| RequestInjection(extension);
|
| - EXPECT_TRUE(controller()->GetActionForExtension(extension));
|
| + EXPECT_TRUE(controller()->WantsToRun(extension));
|
| EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| // Grant active tab.
|
| @@ -324,7 +323,7 @@ TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsUseActiveTabPermissions) {
|
| // The pending injections should have run since active tab permission was
|
| // granted.
|
| EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
| }
|
|
|
| TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsCanHaveAllUrlsPref) {
|
| @@ -359,22 +358,22 @@ TEST_F(ActiveScriptControllerUnitTest, TestAlwaysRun) {
|
|
|
| // Ensure that there aren't any executions pending.
|
| ASSERT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
| - ASSERT_FALSE(controller()->GetActionForExtension(extension));
|
| + ASSERT_FALSE(controller()->WantsToRun(extension));
|
|
|
| // Since the extension requests all_hosts, we should require user consent.
|
| EXPECT_TRUE(RequiresUserConsent(extension));
|
|
|
| - // Request an injection. There should be an action visible, but no executions.
|
| + // Request an injection. The extension should want to run, but not execute.
|
| RequestInjection(extension);
|
| - EXPECT_TRUE(controller()->GetActionForExtension(extension));
|
| + EXPECT_TRUE(controller()->WantsToRun(extension));
|
| EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
|
|
| // Allow the extension to always run on this origin.
|
| controller()->AlwaysRunOnVisibleOrigin(extension);
|
|
|
| - // The extension should execute, and the action should go away.
|
| + // The extension should execute, and the extension shouldn't want to run.
|
| EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
|
| - EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| + EXPECT_FALSE(controller()->WantsToRun(extension));
|
|
|
| // Since we already executed on the given page, we shouldn't need permission
|
| // for a second time.
|
|
|