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/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" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 | 18 |
18 using content::WebContents; | 19 using content::WebContents; |
19 | 20 |
20 class ExtensionOverrideTest : public ExtensionApiTest { | 21 class ExtensionOverrideTest : public ExtensionApiTest { |
21 protected: | 22 protected: |
22 bool CheckHistoryOverridesContainsNoDupes() { | 23 bool CheckHistoryOverridesContainsNoDupes() { |
(...skipping 22 matching lines...) Expand all Loading... |
45 } | 46 } |
46 }; | 47 }; |
47 | 48 |
48 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { | 49 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { |
49 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; | 50 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; |
50 { | 51 { |
51 ResultCatcher catcher; | 52 ResultCatcher catcher; |
52 // Navigate to the new tab page. The overridden new tab page | 53 // Navigate to the new tab page. The overridden new tab page |
53 // will call chrome.test.notifyPass() . | 54 // will call chrome.test.notifyPass() . |
54 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); | 55 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); |
55 WebContents* tab = browser()->GetActiveWebContents(); | 56 WebContents* tab = chrome::GetActiveWebContents(browser()); |
56 ASSERT_TRUE(tab->GetController().GetActiveEntry()); | 57 ASSERT_TRUE(tab->GetController().GetActiveEntry()); |
57 EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL(). | 58 EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL(). |
58 SchemeIs(chrome::kExtensionScheme)); | 59 SchemeIs(chrome::kExtensionScheme)); |
59 | 60 |
60 ASSERT_TRUE(catcher.GetNextResult()); | 61 ASSERT_TRUE(catcher.GetNextResult()); |
61 } | 62 } |
62 | 63 |
63 // TODO(erikkay) Load a second extension with the same override. | 64 // TODO(erikkay) Load a second extension with the same override. |
64 // Verify behavior, then unload the first and verify behavior, etc. | 65 // Verify behavior, then unload the first and verify behavior, etc. |
65 } | 66 } |
66 | 67 |
67 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
68 // Hangy: http://crbug.com/70511 | 69 // Hangy: http://crbug.com/70511 |
69 #define MAYBE_OverrideNewtabIncognito DISABLED_OverrideNewtabIncognito | 70 #define MAYBE_OverrideNewtabIncognito DISABLED_OverrideNewtabIncognito |
70 #else | 71 #else |
71 #define MAYBE_OverrideNewtabIncognito OverrideNewtabIncognito | 72 #define MAYBE_OverrideNewtabIncognito OverrideNewtabIncognito |
72 #endif | 73 #endif |
73 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { | 74 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { |
74 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; | 75 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; |
75 | 76 |
76 // Navigate an incognito tab to the new tab page. We should get the actual | 77 // Navigate an incognito tab to the new tab page. We should get the actual |
77 // new tab page because we can't load chrome-extension URLs in incognito. | 78 // new tab page because we can't load chrome-extension URLs in incognito. |
78 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), | 79 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), |
79 GURL("chrome://newtab/")); | 80 GURL("chrome://newtab/")); |
80 Browser* otr_browser = browser::FindTabbedBrowser( | 81 Browser* otr_browser = browser::FindTabbedBrowser( |
81 browser()->profile()->GetOffTheRecordProfile(), false); | 82 browser()->profile()->GetOffTheRecordProfile(), false); |
82 WebContents* tab = otr_browser->GetActiveWebContents(); | 83 WebContents* tab = chrome::GetActiveWebContents(otr_browser); |
83 ASSERT_TRUE(tab->GetController().GetActiveEntry()); | 84 ASSERT_TRUE(tab->GetController().GetActiveEntry()); |
84 EXPECT_FALSE(tab->GetController().GetActiveEntry()->GetURL(). | 85 EXPECT_FALSE(tab->GetController().GetActiveEntry()->GetURL(). |
85 SchemeIs(chrome::kExtensionScheme)); | 86 SchemeIs(chrome::kExtensionScheme)); |
86 } | 87 } |
87 | 88 |
88 // Times out consistently on Win, http://crbug.com/45173. | 89 // Times out consistently on Win, http://crbug.com/45173. |
89 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
90 #define MAYBE_OverrideHistory DISABLED_OverrideHistory | 91 #define MAYBE_OverrideHistory DISABLED_OverrideHistory |
91 #else | 92 #else |
92 #define MAYBE_OverrideHistory OverrideHistory | 93 #define MAYBE_OverrideHistory OverrideHistory |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ExtensionWebUI::kExtensionURLOverrides); | 135 ExtensionWebUI::kExtensionURLOverrides); |
135 update.Get()->Set("history", list); | 136 update.Get()->Set("history", list); |
136 } | 137 } |
137 | 138 |
138 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 139 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
139 | 140 |
140 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 141 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
141 | 142 |
142 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 143 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
143 } | 144 } |
OLD | NEW |