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

Unified Diff: chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc

Issue 1158693006: Create a mechanism define declarative rules via the extension manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add thread safety to extensionregistry notifications Created 5 years, 6 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/api/declarative_content/declarative_content_apitest.cc
diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc b/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
index 0834e761c5d96fd9572501b3c5a28998cc0d2982..e8fadabff6236032bbb22faba255cdc3ea575b3b 100644
--- a/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
+++ b/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
@@ -314,6 +314,48 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesEvaluatedOnAddRemove) {
EXPECT_FALSE(page_action->GetIsVisible(tab_id));
}
+// Tests that rules from manifest are added and evaluated properly.
+IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesAddedFromManifest) {
+ const char manifest[] =
+ "{\n"
+ " \"name\": \"Declarative Content apitest\",\n"
+ " \"version\": \"0.1\",\n"
+ " \"manifest_version\": 2,\n"
+ " \"page_action\": {},\n"
+ " \"permissions\": [\n"
+ " \"declarativeContent\"\n"
+ " ],\n"
+ " \"event_rules\": [{\n"
+ " \"event\": \"declarativeContent.onPageChanged\",\n"
+ " \"actions\": [{\n"
+ " \"type\": \"declarativeContent.ShowPageAction\"\n"
+ " }],\n"
+ " \"conditions\": [{\n"
+ " \"type\": \"declarativeContent.PageStateMatcher\",\n"
+ " \"pageUrl\": {\"hostPrefix\": \"test1\"}\n"
+ " }]\n"
+ " }]\n"
+ "}\n";
+ ext_dir_.WriteManifest(manifest);
+ const Extension* extension = LoadExtension(ext_dir_.unpacked_path());
+ ASSERT_TRUE(extension);
+ const ExtensionAction* page_action =
+ ExtensionActionManager::Get(browser()->profile())
+ ->GetPageAction(*extension);
+ ASSERT_TRUE(page_action);
+
+ content::WebContents* const tab =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ const int tab_id = ExtensionTabUtil::GetTabId(tab);
+
+ NavigateInRenderer(tab, GURL("http://blank/"));
+ EXPECT_FALSE(page_action->GetIsVisible(tab_id));
+ NavigateInRenderer(tab, GURL("http://test1/"));
+ EXPECT_TRUE(page_action->GetIsVisible(tab_id));
+ NavigateInRenderer(tab, GURL("http://test2/"));
+ EXPECT_FALSE(page_action->GetIsVisible(tab_id));
+}
+
// Tests that rules are not evaluated in incognito browser windows when the
// extension specifies spanning incognito mode but is not enabled for incognito.
IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,

Powered by Google App Engine
This is Rietveld 408576698