| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ui_test_utils::WindowedNotificationObserver bg_pg_created( | 80 ui_test_utils::WindowedNotificationObserver bg_pg_created( |
| 81 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 81 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
| 82 content::NotificationService::AllSources()); | 82 content::NotificationService::AllSources()); |
| 83 ui_test_utils::WindowedNotificationObserver bg_pg_closed( | 83 ui_test_utils::WindowedNotificationObserver bg_pg_closed( |
| 84 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 84 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 85 content::NotificationService::AllSources()); | 85 content::NotificationService::AllSources()); |
| 86 BrowserActionTestUtil(browser()).Press(0); | 86 BrowserActionTestUtil(browser()).Press(0); |
| 87 bg_pg_created.Wait(); | 87 bg_pg_created.Wait(); |
| 88 bg_pg_closed.Wait(); | 88 bg_pg_closed.Wait(); |
| 89 | 89 |
| 90 // Background page is closed before it created a new tab. | 90 // Background page is closed after creating a new tab. |
| 91 // TODO(tessamac): Implement! Close background page after callback. | |
| 92 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 91 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 93 EXPECT_EQ(num_tabs_before, browser()->tab_count()); | 92 EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); |
| 94 } | 93 } |
| 95 | 94 |
| 96 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, | 95 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, |
| 97 BroadcastEvent) { | 96 BroadcastEvent) { |
| 98 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 97 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 99 switches::kEnableLazyBackgroundPages)); | 98 switches::kEnableLazyBackgroundPages)); |
| 100 | 99 |
| 101 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). | 100 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). |
| 102 AppendASCII("broadcast_event"); | 101 AppendASCII("broadcast_event"); |
| 103 ASSERT_TRUE(LoadExtension(extdir)); | 102 ASSERT_TRUE(LoadExtension(extdir)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 119 // cause lazy background pages to be created. | 118 // cause lazy background pages to be created. |
| 120 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 119 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 121 EXPECT_EQ(num_page_actions, // should be + 1 | 120 EXPECT_EQ(num_page_actions, // should be + 1 |
| 122 browser()->window()->GetLocationBar()-> | 121 browser()->window()->GetLocationBar()-> |
| 123 GetLocationBarForTesting()->PageActionVisibleCount()); | 122 GetLocationBarForTesting()->PageActionVisibleCount()); |
| 124 } | 123 } |
| 125 | 124 |
| 126 // TODO: background page with timer. | 125 // TODO: background page with timer. |
| 127 // TODO: background page that interacts with popup. | 126 // TODO: background page that interacts with popup. |
| 128 // TODO: background page with menu. | 127 // TODO: background page with menu. |
| OLD | NEW |