| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file contains tests for extension loading, reloading, and | 5 // This file contains tests for extension loading, reloading, and |
| 6 // unloading behavior. | 6 // unloading behavior. |
| 7 | 7 |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/version.h" | 10 #include "base/version.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class ExtensionLoadingTest : public ExtensionBrowserTest { | 28 class ExtensionLoadingTest : public ExtensionBrowserTest { |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Check the fix for http://crbug.com/178542. | 31 // Check the fix for http://crbug.com/178542. |
| 32 IN_PROC_BROWSER_TEST_F(ExtensionLoadingTest, | 32 IN_PROC_BROWSER_TEST_F(ExtensionLoadingTest, |
| 33 UpgradeAfterNavigatingFromOverriddenNewTabPage) { | 33 UpgradeAfterNavigatingFromOverriddenNewTabPage) { |
| 34 embedded_test_server()->ServeFilesFromDirectory( | 34 embedded_test_server()->ServeFilesFromDirectory( |
| 35 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 35 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 36 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 36 ASSERT_TRUE(embedded_test_server()->Start()); |
| 37 | 37 |
| 38 TestExtensionDir extension_dir; | 38 TestExtensionDir extension_dir; |
| 39 const char manifest_template[] = | 39 const char manifest_template[] = |
| 40 "{" | 40 "{" |
| 41 " 'name': 'Overrides New Tab'," | 41 " 'name': 'Overrides New Tab'," |
| 42 " 'version': '%d'," | 42 " 'version': '%d'," |
| 43 " 'description': 'Overrides New Tab'," | 43 " 'description': 'Overrides New Tab'," |
| 44 " 'manifest_version': 2," | 44 " 'manifest_version': 2," |
| 45 " 'background': {" | 45 " 'background': {" |
| 46 " 'persistent': false," | 46 " 'persistent': false," |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 92 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 93 EXPECT_EQ(0U, registry->terminated_extensions().size()); | 93 EXPECT_EQ(0U, registry->terminated_extensions().size()); |
| 94 EXPECT_TRUE(registry->enabled_extensions().Contains(new_tab_extension->id())); | 94 EXPECT_TRUE(registry->enabled_extensions().Contains(new_tab_extension->id())); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Tests the behavior described in http://crbug.com/532088. | 97 // Tests the behavior described in http://crbug.com/532088. |
| 98 IN_PROC_BROWSER_TEST_F(ExtensionLoadingTest, | 98 IN_PROC_BROWSER_TEST_F(ExtensionLoadingTest, |
| 99 KeepAliveWithDevToolsOpenOnReload) { | 99 KeepAliveWithDevToolsOpenOnReload) { |
| 100 embedded_test_server()->ServeFilesFromDirectory( | 100 embedded_test_server()->ServeFilesFromDirectory( |
| 101 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 101 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 102 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 102 ASSERT_TRUE(embedded_test_server()->Start()); |
| 103 | 103 |
| 104 TestExtensionDir extension_dir; | 104 TestExtensionDir extension_dir; |
| 105 const char manifest_contents[] = | 105 const char manifest_contents[] = |
| 106 "{" | 106 "{" |
| 107 " 'name': 'Test With Lazy Background Page'," | 107 " 'name': 'Test With Lazy Background Page'," |
| 108 " 'version': '0'," | 108 " 'version': '0'," |
| 109 " 'manifest_version': 2," | 109 " 'manifest_version': 2," |
| 110 " 'app': {" | 110 " 'app': {" |
| 111 " 'background': {" | 111 " 'background': {" |
| 112 " 'scripts': ['event.js']" | 112 " 'scripts': ['event.js']" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // The old Extension object is no longer valid. | 149 // The old Extension object is no longer valid. |
| 150 extension = ExtensionRegistry::Get(profile()) | 150 extension = ExtensionRegistry::Get(profile()) |
| 151 ->enabled_extensions().GetByID(extension_id); | 151 ->enabled_extensions().GetByID(extension_id); |
| 152 | 152 |
| 153 // Keepalive count should stabilize back to 1, because DevTools is still open. | 153 // Keepalive count should stabilize back to 1, because DevTools is still open. |
| 154 EXPECT_EQ(1, process_manager->GetLazyKeepaliveCount(extension)); | 154 EXPECT_EQ(1, process_manager->GetLazyKeepaliveCount(extension)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 } // namespace extensions | 158 } // namespace extensions |
| OLD | NEW |