| 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "chrome/browser/extensions/api/management/management_api.h" | 6 #include "chrome/browser/extensions/api/management/management_api.h" |
| 7 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 7 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 9 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 10 #include "chrome/browser/extensions/test_extension_dir.h" | 10 #include "chrome/browser/extensions/test_extension_dir.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const std::string extension_id = extension->id(); | 94 const std::string extension_id = extension->id(); |
| 95 | 95 |
| 96 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages | 96 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages |
| 97 // to reload itself that often without being terminated, the test fails | 97 // to reload itself that often without being terminated, the test fails |
| 98 // anyway. | 98 // anyway. |
| 99 for (int i = 0; i < 30; i++) { | 99 for (int i = 0; i < 30; i++) { |
| 100 content::WindowedNotificationObserver unload_observer( | 100 content::WindowedNotificationObserver unload_observer( |
| 101 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 101 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 102 content::NotificationService::AllSources()); | 102 content::NotificationService::AllSources()); |
| 103 content::WindowedNotificationObserver load_observer( | 103 content::WindowedNotificationObserver load_observer( |
| 104 chrome::NOTIFICATION_EXTENSION_LOADED, | 104 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 105 content::NotificationService::AllSources()); | 105 content::NotificationService::AllSources()); |
| 106 | 106 |
| 107 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( | 107 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( |
| 108 extension_id, "chrome.runtime.reload();")); | 108 extension_id, "chrome.runtime.reload();")); |
| 109 unload_observer.Wait(); | 109 unload_observer.Wait(); |
| 110 | 110 |
| 111 if (registry->GetExtensionById(extension_id, | 111 if (registry->GetExtensionById(extension_id, |
| 112 ExtensionRegistry::TERMINATED)) { | 112 ExtensionRegistry::TERMINATED)) { |
| 113 break; | 113 break; |
| 114 } else { | 114 } else { |
| 115 load_observer.Wait(); | 115 load_observer.Wait(); |
| 116 WaitForExtensionViewsToLoad(); | 116 WaitForExtensionViewsToLoad(); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 ASSERT_TRUE( | 119 ASSERT_TRUE( |
| 120 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); | 120 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace extensions | 123 } // namespace extensions |
| OLD | NEW |