| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/extensions/browser_action_test_util.h" | 16 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 17 #include "chrome/browser/extensions/extension_action_test_util.h" | 17 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 18 #include "chrome/browser/extensions/extension_apitest.h" | 18 #include "chrome/browser/extensions/extension_apitest.h" |
| 19 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 19 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/location_bar/location_bar.h" | 23 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
| 29 #include "components/app_modal/app_modal_dialog.h" | 29 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 30 #include "components/bookmarks/browser/bookmark_model.h" | 30 #include "components/bookmarks/browser/bookmark_model.h" |
| 31 #include "components/bookmarks/browser/bookmark_utils.h" | 31 #include "components/bookmarks/browser/bookmark_utils.h" |
| 32 #include "components/bookmarks/test/bookmark_test_helpers.h" | 32 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "extensions/browser/extension_host.h" | 36 #include "extensions/browser/extension_host.h" |
| 37 #include "extensions/browser/extension_registry.h" | 37 #include "extensions/browser/extension_registry.h" |
| 38 #include "extensions/browser/extension_registry_observer.h" | 38 #include "extensions/browser/extension_registry_observer.h" |
| 39 #include "extensions/browser/process_manager.h" | 39 #include "extensions/browser/process_manager.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 // Tests that a JavaScript alert keeps the lazy background page alive. | 233 // Tests that a JavaScript alert keeps the lazy background page alive. |
| 234 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForDialog) { | 234 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForDialog) { |
| 235 LazyBackgroundObserver background_observer; | 235 LazyBackgroundObserver background_observer; |
| 236 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). | 236 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). |
| 237 AppendASCII("wait_for_dialog"); | 237 AppendASCII("wait_for_dialog"); |
| 238 const Extension* extension = LoadExtension(extdir); | 238 const Extension* extension = LoadExtension(extdir); |
| 239 ASSERT_TRUE(extension); | 239 ASSERT_TRUE(extension); |
| 240 | 240 |
| 241 // The test extension opens a dialog on installation. | 241 // The test extension opens a dialog on installation. |
| 242 app_modal::AppModalDialog* dialog = ui_test_utils::WaitForAppModalDialog(); | 242 app_modal::JavaScriptAppModalDialog* dialog = |
| 243 ui_test_utils::WaitForAppModalDialog(); |
| 243 ASSERT_TRUE(dialog); | 244 ASSERT_TRUE(dialog); |
| 244 | 245 |
| 245 // With the dialog open the background page is still alive. | 246 // With the dialog open the background page is still alive. |
| 246 EXPECT_TRUE(IsBackgroundPageAlive(extension->id())); | 247 EXPECT_TRUE(IsBackgroundPageAlive(extension->id())); |
| 247 | 248 |
| 248 // Close the dialog. The keep alive count is decremented. | 249 // Close the dialog. The keep alive count is decremented. |
| 249 ProcessManager* pm = ProcessManager::Get(browser()->profile()); | 250 ProcessManager* pm = ProcessManager::Get(browser()->profile()); |
| 250 int previous_keep_alive_count = pm->GetLazyKeepaliveCount(extension); | 251 int previous_keep_alive_count = pm->GetLazyKeepaliveCount(extension); |
| 251 dialog->CloseModalDialog(); | 252 dialog->CloseModalDialog(); |
| 252 EXPECT_EQ(previous_keep_alive_count - 1, | 253 EXPECT_EQ(previous_keep_alive_count - 1, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // process does not linger around. | 638 // process does not linger around. |
| 638 // See https://crbug.com/612668. | 639 // See https://crbug.com/612668. |
| 639 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventProcessCleanup) { | 640 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventProcessCleanup) { |
| 640 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); | 641 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); |
| 641 | 642 |
| 642 // Lazy Background Page doesn't exist anymore. | 643 // Lazy Background Page doesn't exist anymore. |
| 643 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 644 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
| 644 } | 645 } |
| 645 | 646 |
| 646 } // namespace extensions | 647 } // namespace extensions |
| OLD | NEW |