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

Unified Diff: chrome/browser/extensions/extension_action_runner_unittest.cc

Issue 1804123003: [Extensions] Refactor extension action execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_action_runner_unittest.cc
diff --git a/chrome/browser/extensions/extension_action_runner_unittest.cc b/chrome/browser/extensions/extension_action_runner_unittest.cc
index badade8995aee09d45a681273fe63b2f42ab3621..2aaff8c1ae4df66337599ff5ed554ca668ba0b92 100644
--- a/chrome/browser/extensions/extension_action_runner_unittest.cc
+++ b/chrome/browser/extensions/extension_action_runner_unittest.cc
@@ -199,9 +199,6 @@ TEST_F(ExtensionActionRunnerUnitTest, RequestPermissionAndExecute) {
ASSERT_EQ(0u, GetExecutionCountForExtension(extension->id()));
ASSERT_FALSE(runner()->WantsToRun(extension));
- ExtensionActionAPI* extension_action_api = ExtensionActionAPI::Get(profile());
- ASSERT_FALSE(extension_action_api->HasBeenBlocked(extension, web_contents()));
-
// Since the extension requests all_hosts, we should require user consent.
EXPECT_TRUE(RequiresUserConsent(extension));
@@ -209,16 +206,14 @@ TEST_F(ExtensionActionRunnerUnitTest, RequestPermissionAndExecute) {
// executed.
RequestInjection(extension);
EXPECT_TRUE(runner()->WantsToRun(extension));
- EXPECT_TRUE(extension_action_api->HasBeenBlocked(extension, web_contents()));
EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
// Click to accept the extension executing.
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
// The extension should execute, and the extension shouldn't want to run.
EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
EXPECT_FALSE(runner()->WantsToRun(extension));
- EXPECT_FALSE(extension_action_api->HasBeenBlocked(extension, web_contents()));
// Since we already executed on the given page, we shouldn't need permission
// for a second time.
@@ -239,7 +234,7 @@ TEST_F(ExtensionActionRunnerUnitTest, RequestPermissionAndExecute) {
// Grant access.
RequestInjection(extension);
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
EXPECT_EQ(2u, GetExecutionCountForExtension(extension->id()));
EXPECT_FALSE(runner()->WantsToRun(extension));
@@ -271,7 +266,7 @@ TEST_F(ExtensionActionRunnerUnitTest, PendingInjectionsRemovedAtNavigation) {
// Request and accept a new injection.
RequestInjection(extension);
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
// The extension should only have executed once, even though a grand total
// of two executions were requested.
@@ -295,7 +290,7 @@ TEST_F(ExtensionActionRunnerUnitTest, MultiplePendingInjection) {
EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
// All pending injections should have executed.
EXPECT_EQ(kNumInjections, GetExecutionCountForExtension(extension->id()));
@@ -393,7 +388,7 @@ TEST_F(ExtensionActionRunnerUnitTest, TestAlwaysRun) {
// Allow the extension to always run on this origin.
ScriptingPermissionsModifier modifier(profile(), extension);
modifier.GrantHostPermission(web_contents()->GetLastCommittedURL());
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
// The extension should execute, and the extension shouldn't want to run.
EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
@@ -449,7 +444,7 @@ TEST_F(ExtensionActionRunnerUnitTest, TestDifferentScriptRunLocations) {
EXPECT_EQ(BLOCKED_ACTION_SCRIPT_AT_START | BLOCKED_ACTION_SCRIPT_OTHER,
runner()->GetBlockedActions(extension));
- runner()->OnClicked(extension);
+ runner()->RunAction(extension, true);
EXPECT_EQ(BLOCKED_ACTION_NONE, runner()->GetBlockedActions(extension));
}

Powered by Google App Engine
This is Rietveld 408576698