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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/prefs/scoped_user_pref_update.h" | 6 #include "base/prefs/scoped_user_pref_update.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_web_ui.h" | 9 #include "chrome/browser/extensions/extension_web_ui.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 if (seen_overrides.find(value) != seen_overrides.end()) | 41 if (seen_overrides.find(value) != seen_overrides.end()) |
42 return false; | 42 return false; |
43 | 43 |
44 seen_overrides.insert(value); | 44 seen_overrides.insert(value); |
45 } | 45 } |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
49 }; | 49 }; |
50 | 50 |
51 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { | 51 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewTab) { |
52 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; | 52 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; |
53 { | 53 { |
54 extensions::ResultCatcher catcher; | 54 extensions::ResultCatcher catcher; |
55 // Navigate to the new tab page. The overridden new tab page | 55 // Navigate to the new tab page. The overridden new tab page |
56 // will call chrome.test.notifyPass() . | 56 // will call chrome.test.notifyPass() . |
57 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); | 57 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); |
58 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 58 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
59 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); | 59 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); |
60 EXPECT_TRUE(tab->GetController().GetVisibleEntry()->GetURL(). | 60 EXPECT_TRUE(tab->GetController().GetVisibleEntry()->GetURL(). |
61 SchemeIs(extensions::kExtensionScheme)); | 61 SchemeIs(extensions::kExtensionScheme)); |
62 | 62 |
63 ASSERT_TRUE(catcher.GetNextResult()); | 63 ASSERT_TRUE(catcher.GetNextResult()); |
64 } | 64 } |
65 | 65 |
66 // TODO(erikkay) Load a second extension with the same override. | 66 // TODO(erikkay) Load a second extension with the same override. |
67 // Verify behavior, then unload the first and verify behavior, etc. | 67 // Verify behavior, then unload the first and verify behavior, etc. |
68 } | 68 } |
69 | 69 |
70 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) |
71 // Hangy: http://crbug.com/70511 | 71 // Hangy: http://crbug.com/70511 |
72 #define MAYBE_OverrideNewtabIncognito DISABLED_OverrideNewtabIncognito | 72 #define MAYBE_OverrideNewTabIncognito DISABLED_OverrideNewTabIncognito |
73 #else | 73 #else |
74 #define MAYBE_OverrideNewtabIncognito OverrideNewtabIncognito | 74 #define MAYBE_OverrideNewTabIncognito OverrideNewTabIncognito |
75 #endif | 75 #endif |
76 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { | 76 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewTabIncognito) { |
77 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; | 77 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; |
78 | 78 |
79 // Navigate an incognito tab to the new tab page. We should get the actual | 79 // Navigate an incognito tab to the new tab page. We should get the actual |
80 // new tab page because we can't load chrome-extension URLs in incognito. | 80 // new tab page because we can't load chrome-extension URLs in incognito. |
81 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 81 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
82 browser()->profile(), GURL("chrome://newtab/")); | 82 browser()->profile(), GURL("chrome://newtab/")); |
83 WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents(); | 83 WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents(); |
84 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); | 84 ASSERT_TRUE(tab->GetController().GetVisibleEntry()); |
85 EXPECT_FALSE(tab->GetController().GetVisibleEntry()->GetURL(). | 85 EXPECT_FALSE(tab->GetController().GetVisibleEntry()->GetURL(). |
86 SchemeIs(extensions::kExtensionScheme)); | 86 SchemeIs(extensions::kExtensionScheme)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 ExtensionWebUI::kExtensionURLOverrides); | 135 ExtensionWebUI::kExtensionURLOverrides); |
136 update.Get()->Set("history", list); | 136 update.Get()->Set("history", list); |
137 } | 137 } |
138 | 138 |
139 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 139 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
140 | 140 |
141 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 141 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
142 | 142 |
143 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 143 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
144 } | 144 } |
OLD | NEW |