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 const Extension* extension = | 117 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
118 LoadExtension(test_data_dir_.AppendASCII("override/history")); | |
119 ASSERT_TRUE(extension); | |
120 | 118 |
121 // Simulate several LoadExtension() calls happening over the lifetime of | 119 // Simulate several LoadExtension() calls happening over the lifetime of |
122 // a preferences file without corresponding UnloadExtension() calls. | 120 // a preferences file without corresponding UnloadExtension() calls. |
123 for (size_t i = 0; i < 3; ++i) { | 121 for (size_t i = 0; i < 3; ++i) { |
124 ExtensionWebUI::RegisterChromeURLOverrides( | 122 ExtensionWebUI::RegisterChromeURLOverrides( |
125 browser()->profile(), | 123 browser()->profile(), |
126 extension->GetChromeURLOverrides()); | 124 browser()->profile()->GetExtensionService()->extensions()->back()-> |
| 125 GetChromeURLOverrides()); |
127 } | 126 } |
128 | 127 |
129 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 128 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
130 } | 129 } |
131 | 130 |
132 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { | 131 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { |
133 // Simulate several LoadExtension() calls happening over the lifetime of | 132 // Simulate several LoadExtension() calls happening over the lifetime of |
134 // a preferences file without corresponding UnloadExtension() calls. This is | 133 // a preferences file without corresponding UnloadExtension() calls. This is |
135 // the same as the above test, except for that it is testing the case where | 134 // the same as the above test, except for that it is testing the case where |
136 // the file already contains dupes when an extension is loaded. | 135 // the file already contains dupes when an extension is loaded. |
(...skipping 17 matching lines...) Expand all Loading... |
154 #if defined(USE_VIRTUAL_KEYBOARD) | 153 #if defined(USE_VIRTUAL_KEYBOARD) |
155 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { | 154 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { |
156 ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; | 155 ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; |
157 { | 156 { |
158 ResultCatcher catcher; | 157 ResultCatcher catcher; |
159 NavigateToKeyboard(); | 158 NavigateToKeyboard(); |
160 ASSERT_TRUE(catcher.GetNextResult()); | 159 ASSERT_TRUE(catcher.GetNextResult()); |
161 } | 160 } |
162 | 161 |
163 // Load the failing version. This should take precedence. | 162 // Load the failing version. This should take precedence. |
164 const Extension* extension = LoadExtension( | 163 ASSERT_TRUE(LoadExtension( |
165 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")); | 164 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails"))); |
166 ASSERT_TRUE(extension); | |
167 { | 165 { |
168 ResultCatcher catcher; | 166 ResultCatcher catcher; |
169 NavigateToKeyboard(); | 167 NavigateToKeyboard(); |
170 ASSERT_FALSE(catcher.GetNextResult()); | 168 ASSERT_FALSE(catcher.GetNextResult()); |
171 } | 169 } |
172 | 170 |
173 // Unload the failing version. We should be back to passing now. | 171 // Unload the failing version. We should be back to passing now. |
174 UnloadExtension(extension->id()); | 172 const ExtensionList *extensions = |
| 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 |