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

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

Issue 1025613003: Fix for ERROR:url_pattern_set.cc(240)] Invalid url pattern: chrome://print/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 8 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/test_extension_prefs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_prefs_unittest.cc
diff --git a/chrome/browser/extensions/extension_prefs_unittest.cc b/chrome/browser/extensions/extension_prefs_unittest.cc
index d9067d3c9daaea0510bb1f46e465f4a605a9b0aa..467c073fb8be29d4659a7b6882aa7674fc1e5785 100644
--- a/chrome/browser/extensions/extension_prefs_unittest.cc
+++ b/chrome/browser/extensions/extension_prefs_unittest.cc
@@ -25,6 +25,7 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/install_flag.h"
#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_info.h"
@@ -913,4 +914,70 @@ class ExtensionPrefsClearLastLaunched : public ExtensionPrefsTest {
};
TEST_F(ExtensionPrefsClearLastLaunched, ExtensionPrefsClearLastLaunched) {}
+class ExtensionPrefsComponentExtension : public ExtensionPrefsTest {
+ public:
+ ~ExtensionPrefsComponentExtension() override {}
+ void Initialize() override {
+ // Adding a component extension.
+ component_extension_ =
+ ExtensionBuilder()
+ .SetManifest(DictionaryBuilder()
+ .Set(manifest_keys::kName, "test")
+ .Set(manifest_keys::kVersion, "0.1"))
+ .SetLocation(Manifest::COMPONENT)
+ .Build();
+ prefs_.AddExtension(component_extension_.get());
+
+ // Adding a non component extension.
not at google - send to devlin 2015/04/13 17:24:35 It would be more consistent to set this up in the
Deepak 2015/04/14 05:05:42 Done.
+ no_component_extension_ = prefs_.AddExtension("a");
+
+ APIPermissionSet api_perms;
+ api_perms.insert(APIPermission::kTab);
+ api_perms.insert(APIPermission::kBookmark);
+ api_perms.insert(APIPermission::kHistory);
+
+ ManifestPermissionSet empty_manifest_permissions;
+
+ URLPatternSet ehosts, shosts;
+ AddPattern(&shosts, "chrome://print/*");
+
+ active_perms_ = new PermissionSet(api_perms, empty_manifest_permissions,
+ ehosts, shosts);
+ // Set the active permissions.
+ prefs()->SetActivePermissions(component_extension_->id(),
+ active_perms_.get());
+ prefs()->SetActivePermissions(no_component_extension_->id(),
+ active_perms_.get());
+ }
+
+ void Verify() override {
+ // Component extension can access chrome://print/*.
+ scoped_refptr<PermissionSet> component_permissions(
+ prefs()->GetActivePermissions(component_extension_->id()));
+ EXPECT_FALSE(component_permissions->scriptable_hosts().is_empty());
not at google - send to devlin 2015/04/13 17:24:35 You should be able to EXPECT_EQ(1u, ....size());
Deepak 2015/04/14 05:05:42 Done.
+
+ // Non Component extension can not access chrome://print/*.
+ scoped_refptr<PermissionSet> no_component_permissions(
+ prefs()->GetActivePermissions(no_component_extension_->id()));
+ EXPECT_TRUE(no_component_permissions->scriptable_hosts().is_empty());
+
+ // |URLPattern::SCHEME_CHROMEUI| scheme will be added in valid_schemes for
+ // component extensions.
+ URLPatternSet scriptable_hosts;
+ std::string pref_key = "active_permissions.scriptable_host";
+ EXPECT_TRUE(prefs()->ReadPrefAsURLPatternSet(
+ component_extension_->id(), pref_key, &scriptable_hosts, 15));
not at google - send to devlin 2015/04/13 17:24:35 What is 15? Can you alias it to something meaningf
Deepak 2015/04/14 05:05:42 Done.
+
+ EXPECT_FALSE(prefs()->ReadPrefAsURLPatternSet(
+ no_component_extension_->id(), pref_key, &scriptable_hosts, 15));
+ }
+
+ private:
+ scoped_refptr<PermissionSet> active_perms_;
+ scoped_refptr<Extension> component_extension_;
+ scoped_refptr<Extension> no_component_extension_;
+};
+TEST_F(ExtensionPrefsComponentExtension, ExtensionPrefsComponentExtension) {
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/test_extension_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698