OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/extension_web_ui.h" | 7 #include "chrome/browser/extensions/extension_web_ui.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 9 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ResultCatcher catcher; | 107 ResultCatcher catcher; |
108 // Navigate to the history page. The overridden history page | 108 // Navigate to the history page. The overridden history page |
109 // will call chrome.test.notifyPass() . | 109 // will call chrome.test.notifyPass() . |
110 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/")); | 110 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/")); |
111 ASSERT_TRUE(catcher.GetNextResult()); | 111 ASSERT_TRUE(catcher.GetNextResult()); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 // Regression test for http://crbug.com/41442. | 115 // Regression test for http://crbug.com/41442. |
116 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { | 116 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { |
117 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 117 const Extension* extension = |
| 118 LoadExtension(test_data_dir_.AppendASCII("override/history")); |
| 119 ASSERT_TRUE(extension); |
118 | 120 |
119 // Simulate several LoadExtension() calls happening over the lifetime of | 121 // Simulate several LoadExtension() calls happening over the lifetime of |
120 // a preferences file without corresponding UnloadExtension() calls. | 122 // a preferences file without corresponding UnloadExtension() calls. |
121 for (size_t i = 0; i < 3; ++i) { | 123 for (size_t i = 0; i < 3; ++i) { |
122 ExtensionWebUI::RegisterChromeURLOverrides( | 124 ExtensionWebUI::RegisterChromeURLOverrides( |
123 browser()->profile(), | 125 browser()->profile(), |
124 browser()->profile()->GetExtensionService()->extensions()->back()-> | 126 extension->GetChromeURLOverrides()); |
125 GetChromeURLOverrides()); | |
126 } | 127 } |
127 | 128 |
128 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 129 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
129 } | 130 } |
130 | 131 |
131 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { | 132 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { |
132 // Simulate several LoadExtension() calls happening over the lifetime of | 133 // Simulate several LoadExtension() calls happening over the lifetime of |
133 // a preferences file without corresponding UnloadExtension() calls. This is | 134 // a preferences file without corresponding UnloadExtension() calls. This is |
134 // the same as the above test, except for that it is testing the case where | 135 // the same as the above test, except for that it is testing the case where |
135 // the file already contains dupes when an extension is loaded. | 136 // the file already contains dupes when an extension is loaded. |
(...skipping 17 matching lines...) Expand all Loading... |
153 #if defined(USE_VIRTUAL_KEYBOARD) | 154 #if defined(USE_VIRTUAL_KEYBOARD) |
154 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { | 155 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { |
155 ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; | 156 ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; |
156 { | 157 { |
157 ResultCatcher catcher; | 158 ResultCatcher catcher; |
158 NavigateToKeyboard(); | 159 NavigateToKeyboard(); |
159 ASSERT_TRUE(catcher.GetNextResult()); | 160 ASSERT_TRUE(catcher.GetNextResult()); |
160 } | 161 } |
161 | 162 |
162 // Load the failing version. This should take precedence. | 163 // Load the failing version. This should take precedence. |
163 ASSERT_TRUE(LoadExtension( | 164 const Extension* extension = LoadExtension( |
164 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails"))); | 165 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")); |
| 166 ASSERT_TRUE(extension); |
165 { | 167 { |
166 ResultCatcher catcher; | 168 ResultCatcher catcher; |
167 NavigateToKeyboard(); | 169 NavigateToKeyboard(); |
168 ASSERT_FALSE(catcher.GetNextResult()); | 170 ASSERT_FALSE(catcher.GetNextResult()); |
169 } | 171 } |
170 | 172 |
171 // Unload the failing version. We should be back to passing now. | 173 // Unload the failing version. We should be back to passing now. |
172 const ExtensionList *extensions = | 174 UnloadExtension(extension->id()); |
173 browser()->profile()->GetExtensionService()->extensions(); | |
174 UnloadExtension((*extensions->rbegin())->id()); | |
175 { | 175 { |
176 ResultCatcher catcher; | 176 ResultCatcher catcher; |
177 NavigateToKeyboard(); | 177 NavigateToKeyboard(); |
178 ASSERT_TRUE(catcher.GetNextResult()); | 178 ASSERT_TRUE(catcher.GetNextResult()); |
179 } | 179 } |
180 } | 180 } |
181 #endif | 181 #endif |
OLD | NEW |