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

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

Issue 23478003: Check and canonicalize CSS selectors before registering PageStateMatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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 c75431674f92be195e45fe94f9edd36926abc379..60d84b4b371a905b74c8f3a6d5f860b601a0b4d9 100644
--- a/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
+++ b/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
@@ -109,5 +109,54 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, Overview) {
EXPECT_FALSE(page_action->GetIsVisible(tab_id));
}
+IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
+ CanonicalizesPageStateMatcherCss) {
+ ext_dir_.WriteManifest(kDeclarativeContentManifest);
+ ext_dir_.WriteFile(
+ FILE_PATH_LITERAL("background.js"),
+ "var declarative = chrome.declarative;\n"
+ "\n"
+ "var PageStateMatcher = chrome.declarativeContent.PageStateMatcher;\n"
+ "\n"
+ "chrome.test.runTests([\n"
+ " function canonicalizesCss() {\n"
+ " var psm = new PageStateMatcher(\n"
Jeffrey Yasskin 2013/08/26 22:35:19 I ought to be able to run these tests entirely on
not at google - send to devlin 2013/08/27 01:46:14 Given we have no way to spin up a fake webkit inst
Jeffrey Yasskin 2013/08/27 19:09:48 There's something to be said, but it tends to take
not at google - send to devlin 2013/08/27 19:39:53 I do wish there was a better pattern for this. Pe
+ " {css: [\"input[type='password']\"]});\n"
+ " chrome.test.assertEq(['input[type=\"password\"]'], psm.css);\n"
+ " chrome.test.succeed();\n"
+ " },\n"
+ "\n"
+ " function throwsOnBadCss() {\n"
+ " function NewPageStateMatcher(obj) {\n"
+ " return new PageStateMatcher(obj);\n"
+ " }"
+ " chrome.test.assertThrows(NewPageStateMatcher,\n"
+ " undefined,\n"
+ " [{css: [\"input''\"]}],\n"
+ " \"Invalid selector: input''\");\n"
+ " chrome.test.succeed();\n"
+ " },\n"
+ // TODO(jyasskin): Let the extension developer know if their
+ // selector list includes a complex selector
+ // (http://dev.w3.org/csswg/selectors4/#structure), since those
+ // are disallowed by WebDocument::watchSelectors().
+ //
+ // " function throwsOnComplexSelector() {\n"
+ // " function NewPageStateMatcher(obj) {\n"
+ // " return new PageStateMatcher(obj);\n"
+ // " }"
+ // " chrome.test.assertThrows(NewPageStateMatcher,\n"
+ // " undefined,\n"
+ // " [{css: [\"div input\"]}],\n"
+ // " 'compound selector');\n"
+ // " chrome.test.succeed();\n"
+ // " },\n"
+ "]);\n"
+ "\n");
+ ResultCatcher catcher;
+ ASSERT_TRUE(LoadExtension(ext_dir_.unpacked_path()));
+ ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
+}
+
} // namespace
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698