Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/extensions/extension_override_apitest.cc

Issue 1940002: Prevent chrome extension URL overrides from applying in incognito mode. (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_dom_ui.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/browser_list.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_dom_ui.h" 8 #include "chrome/browser/extensions/extension_dom_ui.h"
9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/url_constants.h"
8 #include "chrome/test/ui_test_utils.h" 11 #include "chrome/test/ui_test_utils.h"
9 12
10 class ExtensionOverrideTest : public ExtensionApiTest { 13 class ExtensionOverrideTest : public ExtensionApiTest {
11 protected: 14 protected:
12 bool CheckHistoryOverridesContainsNoDupes() { 15 bool CheckHistoryOverridesContainsNoDupes() {
13 // There should be no duplicate entries in the preferences. 16 // There should be no duplicate entries in the preferences.
14 const DictionaryValue* overrides = 17 const DictionaryValue* overrides =
15 browser()->profile()->GetPrefs()->GetDictionary( 18 browser()->profile()->GetPrefs()->GetDictionary(
16 ExtensionDOMUI::kExtensionURLOverrides); 19 ExtensionDOMUI::kExtensionURLOverrides);
17 20
(...skipping 17 matching lines...) Expand all
35 } 38 }
36 }; 39 };
37 40
38 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { 41 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) {
39 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; 42 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_;
40 { 43 {
41 ResultCatcher catcher; 44 ResultCatcher catcher;
42 // Navigate to the new tab page. The overridden new tab page 45 // Navigate to the new tab page. The overridden new tab page
43 // will call chrome.test.notifyPass() . 46 // will call chrome.test.notifyPass() .
44 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); 47 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/"));
48 TabContents* tab = browser()->GetSelectedTabContents();
49 ASSERT_TRUE(tab->controller().GetActiveEntry());
50 EXPECT_TRUE(tab->controller().GetActiveEntry()->url().
51 SchemeIs(chrome::kExtensionScheme));
52
45 ASSERT_TRUE(catcher.GetNextResult()); 53 ASSERT_TRUE(catcher.GetNextResult());
46 } 54 }
47 55
48 // TODO(erikkay) Load a second extension with the same override. 56 // TODO(erikkay) Load a second extension with the same override.
49 // Verify behavior, then unload the first and verify behavior, etc. 57 // Verify behavior, then unload the first and verify behavior, etc.
50 } 58 }
51 59
60 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtabIncognito) {
61 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_;
62 {
Erik does not do reviews 2010/05/04 19:29:49 I don't think you need this {}. That's in the oth
63 // Navigate an incognito tab to the new tab page. We should get the actual
64 // new tab page because we can't load chrome-extension URLs in incognito.
65 ui_test_utils::OpenURLOffTheRecord(browser()->profile(),
66 GURL("chrome://newtab/"));
67 Browser* otr_browser = BrowserList::FindBrowserWithType(
68 browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
69 false);
70 TabContents* tab = otr_browser->GetSelectedTabContents();
71 ASSERT_TRUE(tab->controller().GetActiveEntry());
72 EXPECT_FALSE(tab->controller().GetActiveEntry()->url().
73 SchemeIs(chrome::kExtensionScheme));
74 }
75 }
76
52 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideHistory) { 77 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideHistory) {
53 ASSERT_TRUE(RunExtensionTest("override/history")) << message_; 78 ASSERT_TRUE(RunExtensionTest("override/history")) << message_;
54 { 79 {
55 ResultCatcher catcher; 80 ResultCatcher catcher;
56 // Navigate to the history page. The overridden history page 81 // Navigate to the history page. The overridden history page
57 // will call chrome.test.notifyPass() . 82 // will call chrome.test.notifyPass() .
58 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/")); 83 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/"));
59 ASSERT_TRUE(catcher.GetNextResult()); 84 ASSERT_TRUE(catcher.GetNextResult());
60 } 85 }
61 } 86 }
(...skipping 25 matching lines...) Expand all
87 112
88 browser()->profile()->GetPrefs()->GetMutableDictionary( 113 browser()->profile()->GetPrefs()->GetMutableDictionary(
89 ExtensionDOMUI::kExtensionURLOverrides)->Set(L"history", list); 114 ExtensionDOMUI::kExtensionURLOverrides)->Set(L"history", list);
90 115
91 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); 116 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes());
92 117
93 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); 118 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history")));
94 119
95 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); 120 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
96 } 121 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_dom_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698