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/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
6 #include "chrome/browser/extensions/extension_action.h" | 6 #include "chrome/browser/extensions/extension_action.h" |
7 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 7 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 ui_test_utils::NavigateToURL( | 152 ui_test_utils::NavigateToURL( |
153 browser(), | 153 browser(), |
154 GURL(extension->GetResourceURL("remove_popup.html"))); | 154 GURL(extension->GetResourceURL("remove_popup.html"))); |
155 ASSERT_TRUE(catcher.GetNextResult()); | 155 ASSERT_TRUE(catcher.GetNextResult()); |
156 } | 156 } |
157 | 157 |
158 ASSERT_FALSE(page_action->HasPopup(tab_id)) | 158 ASSERT_FALSE(page_action->HasPopup(tab_id)) |
159 << "Page action popup should have been removed."; | 159 << "Page action popup should have been removed."; |
160 } | 160 } |
161 | 161 |
162 // Tests old-style pageActions API that is deprecated but we don't want to | |
163 // break. | |
164 IN_PROC_BROWSER_TEST_F(PageActionApiTest, OldPageActions) { | |
165 ASSERT_TRUE(RunExtensionTestAllowOldManifestVersion("page_action/old_api")) << | |
166 message_; | |
167 const Extension* extension = GetSingleLoadedExtension(); | |
168 ASSERT_TRUE(extension) << message_; | |
169 | |
170 // Have the extension enable the page action. | |
171 { | |
172 ResultCatcher catcher; | |
173 ui_test_utils::NavigateToURL(browser(), | |
174 GURL(extension->GetResourceURL("page.html"))); | |
175 ASSERT_TRUE(catcher.GetNextResult()); | |
176 } | |
177 | |
178 // Simulate the page action being clicked. | |
179 { | |
180 ResultCatcher catcher; | |
181 int tab_id = ExtensionTabUtil::GetTabId( | |
182 browser()->tab_strip_model()->GetActiveWebContents()); | |
183 ExtensionAction* page_action = GetPageAction(*extension); | |
184 ExtensionActionAPI::PageActionExecuted( | |
185 browser()->profile(), *page_action, tab_id, std::string(), 1); | |
186 EXPECT_TRUE(catcher.GetNextResult()); | |
187 } | |
188 } | |
189 | |
190 // Tests popups in page actions. | 162 // Tests popups in page actions. |
191 // Flaky on the trybots. See http://crbug.com/96725. | 163 // Flaky on the trybots. See http://crbug.com/96725. |
192 IN_PROC_BROWSER_TEST_F(PageActionApiTest, DISABLED_ShowPageActionPopup) { | 164 IN_PROC_BROWSER_TEST_F(PageActionApiTest, DISABLED_ShowPageActionPopup) { |
193 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; | 165 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; |
194 const Extension* extension = GetSingleLoadedExtension(); | 166 const Extension* extension = GetSingleLoadedExtension(); |
195 ASSERT_TRUE(extension) << message_; | 167 ASSERT_TRUE(extension) << message_; |
196 | 168 |
197 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); | 169 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); |
198 | 170 |
199 { | 171 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 const std::string script = | 236 const std::string script = |
265 "window.domAutomationController.send(document.body.style." | 237 "window.domAutomationController.send(document.body.style." |
266 "backgroundColor);"; | 238 "backgroundColor);"; |
267 std::string result; | 239 std::string result; |
268 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); | 240 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); |
269 EXPECT_EQ(result, "red"); | 241 EXPECT_EQ(result, "red"); |
270 } | 242 } |
271 | 243 |
272 } // namespace | 244 } // namespace |
273 } // namespace extensions | 245 } // namespace extensions |
OLD | NEW |