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