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

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

Issue 296483011: Run any pending injections in ActiveScriptController if permission is granted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ben's Created 6 years, 7 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/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 ef3dda80769ce98a252e20dc12d1638d0ede49bd..7b5a36dc568c78282d603e855df26d0674d5c3a1 100644
--- a/chrome/browser/extensions/active_script_controller_unittest.cc
+++ b/chrome/browser/extensions/active_script_controller_unittest.cc
@@ -276,11 +276,27 @@ TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsUseActiveTabPermissions) {
// Since we have active tab permissions, we shouldn't need user consent
// anymore.
- EXPECT_FALSE(
- controller()->RequiresUserConsentForScriptInjection(extension));
+ EXPECT_FALSE(controller()->RequiresUserConsentForScriptInjection(extension));
+
+ // Also test that granting active tab runs any pending tasks.
+ NavigateAndCommit(GURL("https://www.google.com"));
+ // Navigating should mean we need permission again.
+ EXPECT_TRUE(controller()->RequiresUserConsentForScriptInjection(extension));
- // TODO(rdevlin.cronin): We should also implement/test that granting active
- // tab permissions automatically runs any pending injections.
+ controller()->RequestScriptInjection(
+ extension,
+ GetPageId(),
+ GetExecutionCallbackForExtension(extension->id()));
+ EXPECT_TRUE(controller()->GetActionForExtension(extension));
+ EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id()));
+
+ // Grant active tab.
+ active_tab_permission_granter->GrantIfRequested(extension);
+
+ // The pending injections should have run since active tab permission was
+ // granted.
+ EXPECT_EQ(1u, GetExecutionCountForExtension(extension->id()));
+ EXPECT_FALSE(controller()->GetActionForExtension(extension));
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/active_script_controller.cc ('k') | chrome/browser/extensions/active_tab_permission_granter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698