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

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

Issue 475333006: Don't clear the activeTab permission for same-origin navigations when the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments... fix another test Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/active_tab_permission_granter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..06dfba6fac3792eeaa5dbb7ae21bdb2b2ce98a89 100644
--- a/chrome/browser/extensions/active_script_controller_unittest.cc
+++ b/chrome/browser/extensions/active_script_controller_unittest.cc
@@ -194,9 +194,17 @@ TEST_F(ActiveScriptControllerUnitTest, RequestPermissionAndExecute) {
// for a second time.
EXPECT_FALSE(RequiresUserConsent(extension));
- // Reloading should clear those permissions, and we should again require user
- // consent.
+ // Reloading and same-origin navigations shouldn't clear those permissions,
+ // and we shouldn't require user constent again.
Reload();
+ EXPECT_FALSE(RequiresUserConsent(extension));
+ NavigateAndCommit(GURL("https://www.google.com/foo"));
+ EXPECT_FALSE(RequiresUserConsent(extension));
+ NavigateAndCommit(GURL("https://www.google.com/bar"));
+ EXPECT_FALSE(RequiresUserConsent(extension));
+
+ // Cross-origin navigations should clear permissions.
+ NavigateAndCommit(GURL("https://otherdomain.google.com"));
EXPECT_TRUE(RequiresUserConsent(extension));
// Grant access.
@@ -280,9 +288,21 @@ TEST_F(ActiveScriptControllerUnitTest, ActiveScriptsUseActiveTabPermissions) {
// anymore.
EXPECT_FALSE(RequiresUserConsent(extension));
- // Also test that granting active tab runs any pending tasks.
+ // Reloading and other same-origin navigations maintain the permission to
+ // execute.
Reload();
- // Navigating should mean we need permission again.
+ EXPECT_FALSE(RequiresUserConsent(extension));
+ NavigateAndCommit(GURL("https://www.google.com/foo"));
+ EXPECT_FALSE(RequiresUserConsent(extension));
+ NavigateAndCommit(GURL("https://www.google.com/bar"));
+ EXPECT_FALSE(RequiresUserConsent(extension));
+
+ // Navigating to a different origin will require user consent again.
+ NavigateAndCommit(GURL("https://yahoo.com"));
+ EXPECT_TRUE(RequiresUserConsent(extension));
+
+ // Back to the original origin should also re-require constent.
+ NavigateAndCommit(GURL("https://www.google.com"));
EXPECT_TRUE(RequiresUserConsent(extension));
RequestInjection(extension);
« no previous file with comments | « no previous file | chrome/browser/extensions/active_tab_permission_granter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698