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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "extensions/test/result_catcher.h" | 29 #include "extensions/test/result_catcher.h" |
30 #include "net/dns/mock_host_resolver.h" | 30 #include "net/dns/mock_host_resolver.h" |
31 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
32 | 32 |
33 using content::WebContents; | 33 using content::WebContents; |
34 | 34 |
35 namespace extensions { | 35 namespace extensions { |
36 | 36 |
37 class ExtensionOverrideTest : public ExtensionApiTest { | 37 class ExtensionOverrideTest : public ExtensionApiTest { |
38 protected: | 38 protected: |
| 39 void SetUpOnMainThread() override { |
| 40 ExtensionApiTest::SetUpOnMainThread(); |
| 41 host_resolver()->AddRule("*", "127.0.0.1"); |
| 42 ASSERT_TRUE(embedded_test_server()->Start()); |
| 43 } |
| 44 |
39 bool CheckHistoryOverridesContainsNoDupes() { | 45 bool CheckHistoryOverridesContainsNoDupes() { |
40 // There should be no duplicate entries in the preferences. | 46 // There should be no duplicate entries in the preferences. |
41 const base::DictionaryValue* overrides = | 47 const base::DictionaryValue* overrides = |
42 browser()->profile()->GetPrefs()->GetDictionary( | 48 browser()->profile()->GetPrefs()->GetDictionary( |
43 ExtensionWebUI::kExtensionURLOverrides); | 49 ExtensionWebUI::kExtensionURLOverrides); |
44 | 50 |
45 const base::ListValue* values = nullptr; | 51 const base::ListValue* values = nullptr; |
46 if (!overrides->GetList("history", &values)) | 52 if (!overrides->GetList("history", &values)) |
47 return false; | 53 return false; |
48 | 54 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); | 203 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); |
198 EXPECT_FALSE(tab->GetController().GetVisibleEntry()->GetURL(). | 204 EXPECT_FALSE(tab->GetController().GetVisibleEntry()->GetURL(). |
199 SchemeIs(kExtensionScheme)); | 205 SchemeIs(kExtensionScheme)); |
200 } | 206 } |
201 | 207 |
202 // Check that when an overridden new tab page has focus, a subframe navigation | 208 // Check that when an overridden new tab page has focus, a subframe navigation |
203 // on that page does not steal the focus away by focusing the omnibox. | 209 // on that page does not steal the focus away by focusing the omnibox. |
204 // See https://crbug.com/700124. | 210 // See https://crbug.com/700124. |
205 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, | 211 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, |
206 SubframeNavigationInOverridenNTPDoesNotAffectFocus) { | 212 SubframeNavigationInOverridenNTPDoesNotAffectFocus) { |
207 host_resolver()->AddRule("*", "127.0.0.1"); | |
208 ASSERT_TRUE(embedded_test_server()->Start()); | |
209 | |
210 // Load an extension that overrides the new tab page. | 213 // Load an extension that overrides the new tab page. |
211 const Extension* extension = LoadExtension(data_dir().AppendASCII("newtab")); | 214 const Extension* extension = LoadExtension(data_dir().AppendASCII("newtab")); |
212 | 215 |
213 // Navigate to the new tab page. The overridden new tab page | 216 // Navigate to the new tab page. The overridden new tab page |
214 // will call chrome.test.sendMessage('controlled by first'). | 217 // will call chrome.test.sendMessage('controlled by first'). |
215 ExtensionTestMessageListener listener("controlled by first", false); | 218 ExtensionTestMessageListener listener("controlled by first", false); |
216 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 219 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
217 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 220 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
218 EXPECT_TRUE(ExtensionControlsPage(contents, extension->id())); | 221 EXPECT_TRUE(ExtensionControlsPage(contents, extension->id())); |
219 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 222 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 296 } |
294 | 297 |
295 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 298 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
296 | 299 |
297 ExtensionWebUI::InitializeChromeURLOverrides(profile()); | 300 ExtensionWebUI::InitializeChromeURLOverrides(profile()); |
298 | 301 |
299 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 302 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
300 } | 303 } |
301 | 304 |
302 } // namespace extensions | 305 } // namespace extensions |
OLD | NEW |