| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_function_test_utils.h" | 7 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 8 #include "chrome/browser/extensions/test_extension_dir.h" | 8 #include "chrome/browser/extensions/test_extension_dir.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 " \"background\": {" | 90 " \"background\": {" |
| 91 " \"scripts\": [\"background.js\"]" | 91 " \"scripts\": [\"background.js\"]" |
| 92 " }," | 92 " }," |
| 93 " \"manifest_version\": 2" | 93 " \"manifest_version\": 2" |
| 94 "}"; | 94 "}"; |
| 95 | 95 |
| 96 TestExtensionDir dir; | 96 TestExtensionDir dir; |
| 97 dir.WriteManifest(kManifest); | 97 dir.WriteManifest(kManifest); |
| 98 dir.WriteFile(FILE_PATH_LITERAL("background.js"), "console.log('loaded');"); | 98 dir.WriteFile(FILE_PATH_LITERAL("background.js"), "console.log('loaded');"); |
| 99 | 99 |
| 100 const Extension* extension = LoadExtension(dir.unpacked_path()); | 100 const Extension* extension = LoadExtension(dir.UnpackedPath()); |
| 101 ASSERT_TRUE(extension); | 101 ASSERT_TRUE(extension); |
| 102 const std::string extension_id = extension->id(); | 102 const std::string extension_id = extension->id(); |
| 103 | 103 |
| 104 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages | 104 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages |
| 105 // to reload itself that often without being terminated, the test fails | 105 // to reload itself that often without being terminated, the test fails |
| 106 // anyway. | 106 // anyway. |
| 107 for (int i = 0; i < 30; i++) { | 107 for (int i = 0; i < 30; i++) { |
| 108 content::WindowedNotificationObserver unload_observer( | 108 content::WindowedNotificationObserver unload_observer( |
| 109 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 109 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 110 content::NotificationService::AllSources()); | 110 content::NotificationService::AllSources()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 } else { | 122 } else { |
| 123 load_observer.Wait(); | 123 load_observer.Wait(); |
| 124 WaitForExtensionViewsToLoad(); | 124 WaitForExtensionViewsToLoad(); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 ASSERT_TRUE( | 127 ASSERT_TRUE( |
| 128 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); | 128 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |