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