OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser_list.h" | 5 #include "chrome/browser/browser_list.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_dom_ui.h" | 7 #include "chrome/browser/extensions/extension_dom_ui.h" |
8 #include "chrome/browser/extensions/extensions_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/ui_test_utils.h" | 14 #include "chrome/test/ui_test_utils.h" |
15 | 15 |
16 class ExtensionOverrideTest : public ExtensionApiTest { | 16 class ExtensionOverrideTest : public ExtensionApiTest { |
17 protected: | 17 protected: |
18 bool CheckHistoryOverridesContainsNoDupes() { | 18 bool CheckHistoryOverridesContainsNoDupes() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Regression test for http://crbug.com/41442. | 109 // Regression test for http://crbug.com/41442. |
110 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { | 110 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { |
111 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 111 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
112 | 112 |
113 // Simulate several LoadExtension() calls happening over the lifetime of | 113 // Simulate several LoadExtension() calls happening over the lifetime of |
114 // a preferences file without corresponding UnloadExtension() calls. | 114 // a preferences file without corresponding UnloadExtension() calls. |
115 for (size_t i = 0; i < 3; ++i) { | 115 for (size_t i = 0; i < 3; ++i) { |
116 ExtensionDOMUI::RegisterChromeURLOverrides( | 116 ExtensionDOMUI::RegisterChromeURLOverrides( |
117 browser()->profile(), | 117 browser()->profile(), |
118 browser()->profile()->GetExtensionsService()->extensions()->back()-> | 118 browser()->profile()->GetExtensionService()->extensions()->back()-> |
119 GetChromeURLOverrides()); | 119 GetChromeURLOverrides()); |
120 } | 120 } |
121 | 121 |
122 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 122 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
123 } | 123 } |
124 | 124 |
125 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { | 125 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { |
126 // Simulate several LoadExtension() calls happening over the lifetime of | 126 // Simulate several LoadExtension() calls happening over the lifetime of |
127 // a preferences file without corresponding UnloadExtension() calls. This is | 127 // a preferences file without corresponding UnloadExtension() calls. This is |
128 // the same as the above test, except for that it is testing the case where | 128 // the same as the above test, except for that it is testing the case where |
(...skipping 25 matching lines...) Expand all Loading... |
154 ASSERT_TRUE(LoadExtension( | 154 ASSERT_TRUE(LoadExtension( |
155 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails"))); | 155 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails"))); |
156 { | 156 { |
157 ResultCatcher catcher; | 157 ResultCatcher catcher; |
158 NavigateToKeyboard(); | 158 NavigateToKeyboard(); |
159 ASSERT_FALSE(catcher.GetNextResult()); | 159 ASSERT_FALSE(catcher.GetNextResult()); |
160 } | 160 } |
161 | 161 |
162 // Unload the failing version. We should be back to passing now. | 162 // Unload the failing version. We should be back to passing now. |
163 const ExtensionList *extensions = | 163 const ExtensionList *extensions = |
164 browser()->profile()->GetExtensionsService()->extensions(); | 164 browser()->profile()->GetExtensionService()->extensions(); |
165 UnloadExtension((*extensions->rbegin())->id()); | 165 UnloadExtension((*extensions->rbegin())->id()); |
166 { | 166 { |
167 ResultCatcher catcher; | 167 ResultCatcher catcher; |
168 NavigateToKeyboard(); | 168 NavigateToKeyboard(); |
169 ASSERT_TRUE(catcher.GetNextResult()); | 169 ASSERT_TRUE(catcher.GetNextResult()); |
170 } | 170 } |
171 } | 171 } |
172 #endif | 172 #endif |
OLD | NEW |