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

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: Use WebKit::canonicalizeSelector() instead of CSSStyleRule.selectorText 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
« no previous file with comments | « no previous file | chrome/chrome_renderer.gypi » ('j') | chrome/common/extensions/api/test.json » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1baaa7429c327a43274755f994b5b651fc8ca311 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,50 @@ 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"
+ " {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"
+ " /valid.*: input''$/);\n"
+ " chrome.test.succeed();\n"
+ " },\n"
+ "\n"
+ " 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.*: div input$/);\n"
not at google - send to devlin 2013/08/29 15:20:25 invalid types too?
Jeffrey Yasskin 2013/08/29 21:46:43 I'm not sure what you mean here. The actual messag
not at google - send to devlin 2013/08/29 22:24:03 Oh I meant like rather than passing in a string pa
+ " 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
« no previous file with comments | « no previous file | chrome/chrome_renderer.gypi » ('j') | chrome/common/extensions/api/test.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698