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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_renderer.gypi » ('j') | chrome/common/extensions/api/test.json » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_action.h" 5 #include "chrome/browser/extensions/extension_action.h"
6 #include "chrome/browser/extensions/extension_action_manager.h" 6 #include "chrome/browser/extensions/extension_action_manager.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_tab_util.h" 8 #include "chrome/browser/extensions/extension_tab_util.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/extensions/test_extension_dir.h" 10 #include "chrome/browser/extensions/test_extension_dir.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // Remove it again to make sure that reverts the action. 103 // Remove it again to make sure that reverts the action.
104 ASSERT_TRUE(content::ExecuteScript( 104 ASSERT_TRUE(content::ExecuteScript(
105 tab, "document.body.innerHTML = 'Hello world';")); 105 tab, "document.body.innerHTML = 'Hello world';"));
106 // Give the mutation observer a chance to run and send back the 106 // Give the mutation observer a chance to run and send back the
107 // matching-selector update. 107 // matching-selector update.
108 ASSERT_TRUE(content::ExecuteScript(tab, std::string())); 108 ASSERT_TRUE(content::ExecuteScript(tab, std::string()));
109 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); 109 EXPECT_FALSE(page_action->GetIsVisible(tab_id));
110 } 110 }
111 111
112 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
113 CanonicalizesPageStateMatcherCss) {
114 ext_dir_.WriteManifest(kDeclarativeContentManifest);
115 ext_dir_.WriteFile(
116 FILE_PATH_LITERAL("background.js"),
117 "var declarative = chrome.declarative;\n"
118 "\n"
119 "var PageStateMatcher = chrome.declarativeContent.PageStateMatcher;\n"
120 "\n"
121 "chrome.test.runTests([\n"
122 " function canonicalizesCss() {\n"
123 " var psm = new PageStateMatcher(\n"
124 " {css: [\"input[type='password']\"]});\n"
125 " chrome.test.assertEq(['input[type=\"password\"]'], psm.css);\n"
126 " chrome.test.succeed();\n"
127 " },\n"
128 "\n"
129 " function throwsOnBadCss() {\n"
130 " function NewPageStateMatcher(obj) {\n"
131 " return new PageStateMatcher(obj);\n"
132 " }"
133 " chrome.test.assertThrows(NewPageStateMatcher,\n"
134 " undefined,\n"
135 " [{css: [\"input''\"]}],\n"
136 " /valid.*: input''$/);\n"
137 " chrome.test.succeed();\n"
138 " },\n"
139 "\n"
140 " function throwsOnComplexSelector() {\n"
141 " function NewPageStateMatcher(obj) {\n"
142 " return new PageStateMatcher(obj);\n"
143 " }"
144 " chrome.test.assertThrows(NewPageStateMatcher,\n"
145 " undefined,\n"
146 " [{css: [\"div input\"]}],\n"
147 " /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
148 " chrome.test.succeed();\n"
149 " },\n"
150 "]);\n"
151 "\n");
152 ResultCatcher catcher;
153 ASSERT_TRUE(LoadExtension(ext_dir_.unpacked_path()));
154 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
155 }
156
112 } // namespace 157 } // namespace
113 } // namespace extensions 158 } // namespace extensions
OLDNEW
« 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