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

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

Issue 874683005: [Extensions] Enable the scripts-require-action feature based on all-urls pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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_ui_unittest.cc
diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc
index 656e18527f694c11ddda743404d5daf5698be5bc..51ab9e8d50a93ab99148489759d511da4deca4e0 100644
--- a/chrome/browser/extensions/extension_ui_unittest.cc
+++ b/chrome/browser/extensions/extension_ui_unittest.cc
@@ -339,8 +339,7 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
EXPECT_FALSE(result);
// Give the extension all urls.
- util::SetAllowedScriptingOnAllUrls(
- all_urls_extension->id(), profile(), true);
+ util::SetAllowedScriptingOnAllUrls(all_urls_extension->id(), profile(), true);
// Now the extension should both want and have all urls.
value.reset(handler()->CreateExtensionDetailValue(
@@ -358,12 +357,26 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
EXPECT_FALSE(result);
+ // Revoke the first extension's permissions.
+ util::SetAllowedScriptingOnAllUrls(
+ all_urls_extension->id(), profile(), false);
+
// Turn off the switch and load another extension (so permissions are
// re-initialized).
enable_scripts_switch.reset();
- // Even though the extension has the all urls preference, the checkbox
- // shouldn't show up with the switch off.
+ // Since the extension doesn't have access to all urls (but normally would),
+ // the extension should have the "want" flag even with the switch off.
+ value.reset(handler()->CreateExtensionDetailValue(
+ all_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
+ EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
+ EXPECT_FALSE(result);
+
+ // If we grant the extension all urls, then it should no longer "want" it,
+ // since it is back in its normal state (with the switch off).
+ util::SetAllowedScriptingOnAllUrls(all_urls_extension->id(), profile(), true);
value.reset(handler()->CreateExtensionDetailValue(
all_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
@@ -382,7 +395,7 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
EXPECT_FALSE(result);
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
- EXPECT_FALSE(result);
+ EXPECT_TRUE(result);
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698