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

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: Updated metrics 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
« no previous file with comments | « chrome/browser/extensions/crx_installer_browsertest.cc ('k') | chrome/browser/extensions/extension_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ac493fff746aa1ce3aa25d34ade787a9cdc8f004 100644
--- a/chrome/browser/extensions/extension_ui_unittest.cc
+++ b/chrome/browser/extensions/extension_ui_unittest.cc
@@ -329,23 +329,22 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
scoped_ptr<base::DictionaryValue> value(handler()->CreateExtensionDetailValue(
all_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
bool result = false;
- const std::string kWantsAllUrls = "wantsAllUrls";
+ const std::string kShowAllUrls = "showAllUrls";
const std::string kAllowAllUrls = "allowAllUrls";
// The extension should want all urls, but not currently have it.
- EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
+ EXPECT_TRUE(value->GetBoolean(kShowAllUrls, &result));
EXPECT_TRUE(result);
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
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(
all_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
- EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
+ EXPECT_TRUE(value->GetBoolean(kShowAllUrls, &result));
EXPECT_TRUE(result);
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
EXPECT_TRUE(result);
@@ -353,20 +352,34 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
// The other extension should neither want nor have all urls.
value.reset(handler()->CreateExtensionDetailValue(
no_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
- EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
+ EXPECT_TRUE(value->GetBoolean(kShowAllUrls, &result));
EXPECT_FALSE(result);
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(value->GetBoolean(kShowAllUrls, &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(kShowAllUrls, &result));
EXPECT_FALSE(result);
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
EXPECT_TRUE(result);
@@ -379,10 +392,10 @@ TEST_F(ExtensionUITest, ExtensionUIAllUrlsCheckbox) {
// show up without the switch.
value.reset(handler()->CreateExtensionDetailValue(
all_urls_extension.get(), std::vector<ExtensionPage>(), NULL));
- EXPECT_TRUE(value->GetBoolean(kWantsAllUrls, &result));
+ EXPECT_TRUE(value->GetBoolean(kShowAllUrls, &result));
EXPECT_FALSE(result);
EXPECT_TRUE(value->GetBoolean(kAllowAllUrls, &result));
- EXPECT_FALSE(result);
+ EXPECT_TRUE(result);
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/crx_installer_browsertest.cc ('k') | chrome/browser/extensions/extension_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698