Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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" | |
|
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
| |
| 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 " \"Invalid selector: input''\");\n" | |
| 137 " chrome.test.succeed();\n" | |
| 138 " },\n" | |
| 139 // TODO(jyasskin): Let the extension developer know if their | |
| 140 // selector list includes a complex selector | |
| 141 // (http://dev.w3.org/csswg/selectors4/#structure), since those | |
| 142 // are disallowed by WebDocument::watchSelectors(). | |
| 143 // | |
| 144 // " function throwsOnComplexSelector() {\n" | |
| 145 // " function NewPageStateMatcher(obj) {\n" | |
| 146 // " return new PageStateMatcher(obj);\n" | |
| 147 // " }" | |
| 148 // " chrome.test.assertThrows(NewPageStateMatcher,\n" | |
| 149 // " undefined,\n" | |
| 150 // " [{css: [\"div input\"]}],\n" | |
| 151 // " 'compound selector');\n" | |
| 152 // " chrome.test.succeed();\n" | |
| 153 // " },\n" | |
| 154 "]);\n" | |
| 155 "\n"); | |
| 156 ResultCatcher catcher; | |
| 157 ASSERT_TRUE(LoadExtension(ext_dir_.unpacked_path())); | |
| 158 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
| 159 } | |
| 160 | |
| 112 } // namespace | 161 } // namespace |
| 113 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |