| 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/scoped_observer.h" | 7 #include "base/scoped_observer.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ASSERT_TRUE(extension); | 166 ASSERT_TRUE(extension); |
| 167 | 167 |
| 168 // Lazy Background Page doesn't exist yet. | 168 // Lazy Background Page doesn't exist yet. |
| 169 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 169 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
| 170 int num_page_actions = browser()->window()->GetLocationBar()-> | 170 int num_page_actions = browser()->window()->GetLocationBar()-> |
| 171 GetLocationBarForTesting()->PageActionVisibleCount(); | 171 GetLocationBarForTesting()->PageActionVisibleCount(); |
| 172 | 172 |
| 173 // Open a tab to a URL that will trigger the page action to show. | 173 // Open a tab to a URL that will trigger the page action to show. |
| 174 LazyBackgroundObserver page_complete; | 174 LazyBackgroundObserver page_complete; |
| 175 content::WindowedNotificationObserver page_action_changed( | 175 content::WindowedNotificationObserver page_action_changed( |
| 176 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 176 extensions::NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED, |
| 177 content::NotificationService::AllSources()); | 177 content::NotificationService::AllSources()); |
| 178 ui_test_utils::NavigateToURL( | 178 ui_test_utils::NavigateToURL( |
| 179 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); | 179 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); |
| 180 page_complete.Wait(); | 180 page_complete.Wait(); |
| 181 | 181 |
| 182 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 182 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
| 183 | 183 |
| 184 // Page action is shown. | 184 // Page action is shown. |
| 185 page_action_changed.Wait(); | 185 page_action_changed.Wait(); |
| 186 EXPECT_EQ(num_page_actions + 1, | 186 EXPECT_EQ(num_page_actions + 1, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 569 |
| 570 // Tests that the lazy background page will be unloaded if the onSuspend event | 570 // Tests that the lazy background page will be unloaded if the onSuspend event |
| 571 // handler calls an API function such as chrome.storage.local.set(). | 571 // handler calls an API function such as chrome.storage.local.set(). |
| 572 // See: http://crbug.com/296834 | 572 // See: http://crbug.com/296834 |
| 573 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { | 573 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { |
| 574 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); | 574 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); |
| 575 } | 575 } |
| 576 | 576 |
| 577 // TODO: background page with timer. | 577 // TODO: background page with timer. |
| 578 // TODO: background page that interacts with popup. | 578 // TODO: background page that interacts with popup. |
| OLD | NEW |