| 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_action_runner.h" | 9 #include "chrome/browser/extensions/extension_action_runner.h" |
| 10 #include "chrome/browser/extensions/extension_action_test_util.h" | 10 #include "chrome/browser/extensions/extension_action_test_util.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ExtensionActionRunner::GetForWebContents( | 108 ExtensionActionRunner::GetForWebContents( |
| 109 browser()->tab_strip_model()->GetActiveWebContents()) | 109 browser()->tab_strip_model()->GetActiveWebContents()) |
| 110 ->RunAction(extension, true); | 110 ->RunAction(extension, true); |
| 111 ASSERT_TRUE(catcher.GetNextResult()); | 111 ASSERT_TRUE(catcher.GetNextResult()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 ASSERT_TRUE(page_action->HasPopup(tab_id)) | 114 ASSERT_TRUE(page_action->HasPopup(tab_id)) |
| 115 << "Clicking on the page action should have caused a popup to be added."; | 115 << "Clicking on the page action should have caused a popup to be added."; |
| 116 | 116 |
| 117 ASSERT_STREQ("/a_popup.html", | 117 ASSERT_STREQ("/a_popup.html", |
| 118 page_action->GetPopupUrl(tab_id).path().c_str()); | 118 page_action->GetPopupUrl(tab_id).path().as_string().c_str()); |
| 119 | 119 |
| 120 // Now change the popup from a_popup.html to a_second_popup.html . | 120 // Now change the popup from a_popup.html to a_second_popup.html . |
| 121 // Load a page which removes the popup using chrome.pageAction.setPopup(). | 121 // Load a page which removes the popup using chrome.pageAction.setPopup(). |
| 122 { | 122 { |
| 123 ResultCatcher catcher; | 123 ResultCatcher catcher; |
| 124 ui_test_utils::NavigateToURL( | 124 ui_test_utils::NavigateToURL( |
| 125 browser(), | 125 browser(), |
| 126 GURL(extension->GetResourceURL("change_popup.html"))); | 126 GURL(extension->GetResourceURL("change_popup.html"))); |
| 127 ASSERT_TRUE(catcher.GetNextResult()); | 127 ASSERT_TRUE(catcher.GetNextResult()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 ASSERT_TRUE(page_action->HasPopup(tab_id)); | 130 ASSERT_TRUE(page_action->HasPopup(tab_id)); |
| 131 ASSERT_STREQ("/another_popup.html", | 131 ASSERT_STREQ("/another_popup.html", |
| 132 page_action->GetPopupUrl(tab_id).path().c_str()); | 132 page_action->GetPopupUrl(tab_id).path().as_string().c_str()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Test that calling chrome.pageAction.setPopup() can remove a popup. | 135 // Test that calling chrome.pageAction.setPopup() can remove a popup. |
| 136 IN_PROC_BROWSER_TEST_F(PageActionApiTest, RemovePopup) { | 136 IN_PROC_BROWSER_TEST_F(PageActionApiTest, RemovePopup) { |
| 137 // Load the extension, which has a page action with a default popup. | 137 // Load the extension, which has a page action with a default popup. |
| 138 ASSERT_TRUE(RunExtensionTest("page_action/remove_popup")) << message_; | 138 ASSERT_TRUE(RunExtensionTest("page_action/remove_popup")) << message_; |
| 139 const Extension* extension = GetSingleLoadedExtension(); | 139 const Extension* extension = GetSingleLoadedExtension(); |
| 140 ASSERT_TRUE(extension) << message_; | 140 ASSERT_TRUE(extension) << message_; |
| 141 | 141 |
| 142 int tab_id = ExtensionTabUtil::GetTabId( | 142 int tab_id = ExtensionTabUtil::GetTabId( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 const std::string script = | 242 const std::string script = |
| 243 "window.domAutomationController.send(document.body.style." | 243 "window.domAutomationController.send(document.body.style." |
| 244 "backgroundColor);"; | 244 "backgroundColor);"; |
| 245 std::string result; | 245 std::string result; |
| 246 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); | 246 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); |
| 247 EXPECT_EQ(result, "red"); | 247 EXPECT_EQ(result, "red"); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace | 250 } // namespace |
| 251 } // namespace extensions | 251 } // namespace extensions |
| OLD | NEW |