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 "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/extensions/browser_action_test_util.h" | 16 #include "chrome/browser/extensions/browser_action_test_util.h" |
16 #include "chrome/browser/extensions/extension_action_test_util.h" | 17 #include "chrome/browser/extensions/extension_action_test_util.h" |
17 #include "chrome/browser/extensions/extension_apitest.h" | 18 #include "chrome/browser/extensions/extension_apitest.h" |
18 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 19 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/ui/location_bar/location_bar.h" | 23 #include "chrome/browser/ui/location_bar/location_bar.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); | 312 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); |
312 } | 313 } |
313 | 314 |
314 // Tests that the lazy background page stays alive while a NaCl module exists in | 315 // Tests that the lazy background page stays alive while a NaCl module exists in |
315 // its DOM. | 316 // its DOM. |
316 #if !defined(DISABLE_NACL) | 317 #if !defined(DISABLE_NACL) |
317 | 318 |
318 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInBackgroundPage) { | 319 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInBackgroundPage) { |
319 { | 320 { |
320 base::FilePath extdir; | 321 base::FilePath extdir; |
| 322 base::ThreadRestrictions::ScopedAllowIO allow_io; |
321 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir)); | 323 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir)); |
322 extdir = extdir.AppendASCII("ppapi/tests/extensions/load_unload/newlib"); | 324 extdir = extdir.AppendASCII("ppapi/tests/extensions/load_unload/newlib"); |
323 LazyBackgroundObserver page_complete; | 325 LazyBackgroundObserver page_complete; |
324 ASSERT_TRUE(LoadExtension(extdir)); | 326 ASSERT_TRUE(LoadExtension(extdir)); |
325 page_complete.Wait(); | 327 page_complete.Wait(); |
326 } | 328 } |
327 | 329 |
328 // The NaCl module is loaded, and the Lazy Background Page stays alive. | 330 // The NaCl module is loaded, and the Lazy Background Page stays alive. |
329 { | 331 { |
330 ExtensionTestMessageListener nacl_module_loaded("nacl_module_loaded", | 332 ExtensionTestMessageListener nacl_module_loaded("nacl_module_loaded", |
(...skipping 16 matching lines...) Expand all Loading... |
347 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 349 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
348 } | 350 } |
349 | 351 |
350 // Tests that the lazy background page shuts down when all visible views with | 352 // Tests that the lazy background page shuts down when all visible views with |
351 // NaCl modules are closed. | 353 // NaCl modules are closed. |
352 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInView) { | 354 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInView) { |
353 // The extension is loaded and should've opened a new tab to an extension | 355 // The extension is loaded and should've opened a new tab to an extension |
354 // page, and the Lazy Background Page stays alive. | 356 // page, and the Lazy Background Page stays alive. |
355 { | 357 { |
356 base::FilePath extdir; | 358 base::FilePath extdir; |
| 359 base::ThreadRestrictions::ScopedAllowIO allow_io; |
357 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir)); | 360 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir)); |
358 extdir = extdir.AppendASCII("ppapi/tests/extensions/popup/newlib"); | 361 extdir = extdir.AppendASCII("ppapi/tests/extensions/popup/newlib"); |
359 ResultCatcher catcher; | 362 ResultCatcher catcher; |
360 const Extension* extension = LoadExtension(extdir); | 363 const Extension* extension = LoadExtension(extdir); |
361 ASSERT_TRUE(extension); | 364 ASSERT_TRUE(extension); |
362 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 365 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
363 EXPECT_EQ( | 366 EXPECT_EQ( |
364 extension->GetResourceURL("popup.html").spec(), | 367 extension->GetResourceURL("popup.html").spec(), |
365 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec()); | 368 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec()); |
366 EXPECT_TRUE(IsBackgroundPageAlive(last_loaded_extension_id())); | 369 EXPECT_TRUE(IsBackgroundPageAlive(last_loaded_extension_id())); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // See https://crbug.com/612668. | 658 // See https://crbug.com/612668. |
656 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageIsolatedExtensionsApiTest, | 659 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageIsolatedExtensionsApiTest, |
657 EventProcessCleanup) { | 660 EventProcessCleanup) { |
658 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); | 661 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); |
659 | 662 |
660 // Lazy Background Page doesn't exist anymore. | 663 // Lazy Background Page doesn't exist anymore. |
661 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 664 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
662 } | 665 } |
663 | 666 |
664 } // namespace extensions | 667 } // namespace extensions |
OLD | NEW |