| 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 01fe26ba0cf72bcc319482f4dd6684c120a1d75c..39bd856e453564baf1fcbc63ede047a59837ebd8 100644
|
| --- a/chrome/browser/extensions/active_script_controller_unittest.cc
|
| +++ b/chrome/browser/extensions/active_script_controller_unittest.cc
|
| @@ -322,4 +322,49 @@ TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsCanHaveAllUrlsPref) {
|
| EXPECT_TRUE(RequiresUserConsent(extension));
|
| }
|
|
|
| +TEST_F(ActiveScriptControllerUnitTest, TestAlwaysRun) {
|
| + const Extension* extension = AddExtension();
|
| + ASSERT_TRUE(extension);
|
| +
|
| + NavigateAndCommit(GURL("https://www.google.com/?gws_rd=ssl"));
|
| +
|
| + // Ensure that there aren't any executions pending.
|
| + ASSERT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
| + ASSERT_FALSE(controller()->GetActionForExtension(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.
|
| + RequestInjection(extension);
|
| + EXPECT_TRUE(controller()->GetActionForExtension(extension));
|
| + EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
|
| +
|
| + // Simulate clicking "always run" menu item.
|
| + controller()->AlwaysRunOnVisibleHost(extension);
|
| +
|
| + // The extension should execute, and the action should go away.
|
| + EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
|
| + EXPECT_FALSE(controller()->GetActionForExtension(extension));
|
| +
|
| + // Since we already executed on the given page, we shouldn't need permission
|
| + // for a second time.
|
| + EXPECT_FALSE(RequiresUserConsent(extension));
|
| +
|
| + // Navigating to another site that hasn't been granted a persisted permission
|
| + // should necessitate user consent.
|
| + NavigateAndCommit(GURL("https://www.foo.com/bar"));
|
| + EXPECT_TRUE(RequiresUserConsent(extension));
|
| +
|
| + // We shouldn't need user permission upon returning to the original host.
|
| + NavigateAndCommit(GURL("https://www.google.com/?gws_rd=ssl"));
|
| + EXPECT_FALSE(RequiresUserConsent(extension));
|
| +
|
| + // Reinitializing permissions should clear active permissions, but not
|
| + // persisted permissions.
|
| + PermissionsUpdater(profile()).InitializePermissions(extension);
|
| + Reload();
|
| + EXPECT_FALSE(RequiresUserConsent(extension));
|
| +}
|
| +
|
| } // namespace extensions
|
|
|