| 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" |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // Tests that the lazy background page will be unloaded if the onSuspend event | 622 // Tests that the lazy background page will be unloaded if the onSuspend event |
| 623 // handler calls an API function such as chrome.storage.local.set(). | 623 // handler calls an API function such as chrome.storage.local.set(). |
| 624 // See: http://crbug.com/296834 | 624 // See: http://crbug.com/296834 |
| 625 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { | 625 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { |
| 626 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); | 626 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); |
| 627 } | 627 } |
| 628 | 628 |
| 629 // TODO: background page with timer. | 629 // TODO: background page with timer. |
| 630 // TODO: background page that interacts with popup. | 630 // TODO: background page that interacts with popup. |
| 631 | 631 |
| 632 // Test class to allow test cases to run in --isolate-extensions mode. | |
| 633 class LazyBackgroundPageIsolatedExtensionsApiTest | |
| 634 : public LazyBackgroundPageApiTest { | |
| 635 public: | |
| 636 LazyBackgroundPageIsolatedExtensionsApiTest() {} | |
| 637 ~LazyBackgroundPageIsolatedExtensionsApiTest() override {} | |
| 638 | |
| 639 void SetUpInProcessBrowserTestFixture() override { | |
| 640 LazyBackgroundPageApiTest::SetUpInProcessBrowserTestFixture(); | |
| 641 | |
| 642 // This is needed to allow example.com to actually resolve and load in | |
| 643 // tests. | |
| 644 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 645 } | |
| 646 | |
| 647 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 648 LazyBackgroundPageApiTest::SetUpCommandLine(command_line); | |
| 649 command_line->AppendSwitch(switches::kIsolateExtensions); | |
| 650 } | |
| 651 | |
| 652 private: | |
| 653 DISALLOW_COPY_AND_ASSIGN(LazyBackgroundPageIsolatedExtensionsApiTest); | |
| 654 }; | |
| 655 | |
| 656 // Ensure that the events page of an extension is properly torn down and the | 632 // Ensure that the events page of an extension is properly torn down and the |
| 657 // process does not linger around when running in --isolate-extensions mode. | 633 // process does not linger around. |
| 658 // See https://crbug.com/612668. | 634 // See https://crbug.com/612668. |
| 659 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageIsolatedExtensionsApiTest, | 635 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventProcessCleanup) { |
| 660 EventProcessCleanup) { | |
| 661 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); | 636 ASSERT_TRUE(LoadExtensionAndWait("event_page_with_web_iframe")); |
| 662 | 637 |
| 663 // Lazy Background Page doesn't exist anymore. | 638 // Lazy Background Page doesn't exist anymore. |
| 664 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); | 639 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); |
| 665 } | 640 } |
| 666 | 641 |
| 667 } // namespace extensions | 642 } // namespace extensions |
| OLD | NEW |