| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/extensions/browser_action_test_util.h" | 9 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 161 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 162 | 162 |
| 163 // Page action is shown. | 163 // Page action is shown. |
| 164 page_action_changed.Wait(); | 164 page_action_changed.Wait(); |
| 165 EXPECT_EQ(num_page_actions + 1, | 165 EXPECT_EQ(num_page_actions + 1, |
| 166 browser()->window()->GetLocationBar()-> | 166 browser()->window()->GetLocationBar()-> |
| 167 GetLocationBarForTesting()->PageActionVisibleCount()); | 167 GetLocationBarForTesting()->PageActionVisibleCount()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Filters) { |
| 171 const Extension* extension = LoadExtensionAndWait("filters"); |
| 172 ASSERT_TRUE(extension); |
| 173 |
| 174 // Lazy Background Page doesn't exist yet. |
| 175 ExtensionProcessManager* pm = |
| 176 browser()->profile()->GetExtensionProcessManager(); |
| 177 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 178 |
| 179 // Open a tab to a URL that will fire a webNavigation event. |
| 180 LazyBackgroundObserver page_complete; |
| 181 ui_test_utils::NavigateToURL( |
| 182 browser(), test_server()->GetURL("files/extensions/test_file.html")); |
| 183 page_complete.Wait(); |
| 184 } |
| 185 |
| 170 // Tests that the lazy background page receives the onInstalled event and shuts | 186 // Tests that the lazy background page receives the onInstalled event and shuts |
| 171 // down. | 187 // down. |
| 172 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnInstalled) { | 188 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnInstalled) { |
| 173 ResultCatcher catcher; | 189 ResultCatcher catcher; |
| 174 ASSERT_TRUE(LoadExtensionAndWait("on_installed")); | 190 ASSERT_TRUE(LoadExtensionAndWait("on_installed")); |
| 175 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 191 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 176 | 192 |
| 177 // Lazy Background Page has been shut down. | 193 // Lazy Background Page has been shut down. |
| 178 ExtensionProcessManager* pm = | 194 ExtensionProcessManager* pm = |
| 179 browser()->profile()->GetExtensionProcessManager(); | 195 browser()->profile()->GetExtensionProcessManager(); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 369 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 354 | 370 |
| 355 // The browser action has a new title. | 371 // The browser action has a new title. |
| 356 BrowserActionTestUtil browser_action(browser()); | 372 BrowserActionTestUtil browser_action(browser()); |
| 357 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); | 373 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); |
| 358 EXPECT_EQ("Success", browser_action.GetTooltip(0)); | 374 EXPECT_EQ("Success", browser_action.GetTooltip(0)); |
| 359 } | 375 } |
| 360 | 376 |
| 361 // TODO: background page with timer. | 377 // TODO: background page with timer. |
| 362 // TODO: background page that interacts with popup. | 378 // TODO: background page that interacts with popup. |
| OLD | NEW |