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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 11818036: Revert 175822 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « content/public/common/url_constants.cc ('k') | content/renderer/render_view_impl.cc » ('j') | 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) 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/basictypes.h" 5 #include "base/basictypes.h"
6 6
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/common/intents_messages.h" 10 #include "content/common/intents_messages.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 virtual WebUIController* CreateWebUIControllerForURL( 89 virtual WebUIController* CreateWebUIControllerForURL(
90 WebUI* web_ui, const GURL& url) const OVERRIDE { 90 WebUI* web_ui, const GURL& url) const OVERRIDE {
91 return NULL; 91 return NULL;
92 } 92 }
93 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, 93 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
94 const GURL& url) const OVERRIDE { 94 const GURL& url) const OVERRIDE {
95 return WebUI::kNoWebUI; 95 return WebUI::kNoWebUI;
96 } 96 }
97 virtual bool UseWebUIForURL(BrowserContext* browser_context, 97 virtual bool UseWebUIForURL(BrowserContext* browser_context,
98 const GURL& url) const OVERRIDE { 98 const GURL& url) const OVERRIDE {
99 return HasWebUIScheme(url); 99 return GetContentClient()->HasWebUIScheme(url);
100 } 100 }
101 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, 101 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
102 const GURL& url) const OVERRIDE { 102 const GURL& url) const OVERRIDE {
103 return HasWebUIScheme(url); 103 return GetContentClient()->HasWebUIScheme(url);
104 } 104 }
105 virtual bool IsURLAcceptableForWebUI( 105 virtual bool IsURLAcceptableForWebUI(
106 BrowserContext* browser_context, 106 BrowserContext* browser_context,
107 const GURL& url, 107 const GURL& url,
108 bool data_urls_allowed) const OVERRIDE { 108 bool data_urls_allowed) const OVERRIDE {
109 return false; 109 return false;
110 } 110 }
111 }; 111 };
112 112
113 class WebUITestClient : public ShellContentClient {
114 public:
115 WebUITestClient() {
116 }
117
118 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
119 return url.SchemeIs(chrome::kChromeUIScheme);
120 }
121 };
122
123 class WebUITestBrowserClient : public ShellContentBrowserClient {
124 public:
125 WebUITestBrowserClient() {}
126
127 virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE {
128 return &factory_;
129 }
130
131 private:
132 WebUITestWebUIControllerFactory factory_;
133 };
134
113 } // namespace 135 } // namespace
114 136
115 class RenderViewImplTest : public RenderViewTest { 137 class RenderViewImplTest : public RenderViewTest {
116 public: 138 public:
117 RenderViewImplTest() { 139 RenderViewImplTest() {
118 // Attach a pseudo keyboard device to this object. 140 // Attach a pseudo keyboard device to this object.
119 mock_keyboard_.reset(new MockKeyboard()); 141 mock_keyboard_.reset(new MockKeyboard());
120 } 142 }
121 143
122 RenderViewImpl* view() { 144 RenderViewImpl* view() {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 WebKit::WebHTTPBody body = item.httpBody(); 335 WebKit::WebHTTPBody body = item.httpBody();
314 WebKit::WebHTTPBody::Element element; 336 WebKit::WebHTTPBody::Element element;
315 bool successful = body.elementAt(0, element); 337 bool successful = body.elementAt(0, element);
316 EXPECT_TRUE(successful); 338 EXPECT_TRUE(successful);
317 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type); 339 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type);
318 EXPECT_EQ(length, element.data.size()); 340 EXPECT_EQ(length, element.data.size());
319 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); 341 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length));
320 } 342 }
321 343
322 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { 344 TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
323 WebUITestWebUIControllerFactory factory; 345 WebUITestClient client;
324 WebUIControllerFactory::RegisterFactory(&factory); 346 WebUITestBrowserClient browser_client;
347 ContentClient* old_client = GetContentClient();
348 ContentBrowserClient* old_browser_client = GetContentClient()->browser();
349
350 SetContentClient(&client);
351 GetContentClient()->set_browser_for_testing(&browser_client);
352 client.set_renderer_for_testing(old_client->renderer());
325 353
326 // Navigations to normal HTTP URLs can be handled locally. 354 // Navigations to normal HTTP URLs can be handled locally.
327 WebKit::WebURLRequest request(GURL("http://foo.com")); 355 WebKit::WebURLRequest request(GURL("http://foo.com"));
328 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( 356 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
329 GetMainFrame(), 357 GetMainFrame(),
330 request, 358 request,
331 WebKit::WebNavigationTypeLinkClicked, 359 WebKit::WebNavigationTypeLinkClicked,
332 WebKit::WebNode(), 360 WebKit::WebNode(),
333 WebKit::WebNavigationPolicyCurrentTab, 361 WebKit::WebNavigationPolicyCurrentTab,
334 false); 362 false);
(...skipping 14 matching lines...) Expand all
349 // Verify that popup links to WebUI URLs also are sent to browser. 377 // Verify that popup links to WebUI URLs also are sent to browser.
350 WebKit::WebURLRequest popup_request(GURL("chrome://foo")); 378 WebKit::WebURLRequest popup_request(GURL("chrome://foo"));
351 policy = view()->decidePolicyForNavigation( 379 policy = view()->decidePolicyForNavigation(
352 GetMainFrame(), 380 GetMainFrame(),
353 popup_request, 381 popup_request,
354 WebKit::WebNavigationTypeLinkClicked, 382 WebKit::WebNavigationTypeLinkClicked,
355 WebKit::WebNode(), 383 WebKit::WebNode(),
356 WebKit::WebNavigationPolicyNewForegroundTab, 384 WebKit::WebNavigationPolicyNewForegroundTab,
357 false); 385 false);
358 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); 386 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy);
387
388 GetContentClient()->set_browser_for_testing(old_browser_client);
389 SetContentClient(old_client);
359 } 390 }
360 391
361 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { 392 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
362 // Enable bindings to simulate a WebUI view. 393 // Enable bindings to simulate a WebUI view.
363 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI); 394 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI);
364 395
365 // Navigations to normal HTTP URLs will be sent to browser process. 396 // Navigations to normal HTTP URLs will be sent to browser process.
366 WebKit::WebURLRequest request(GURL("http://foo.com")); 397 WebKit::WebURLRequest request(GURL("http://foo.com"));
367 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( 398 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
368 GetMainFrame(), 399 GetMainFrame(),
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 EXPECT_EQ(7, info.selectionEnd); 1853 EXPECT_EQ(7, info.selectionEnd);
1823 view()->OnSetEditableSelectionOffsets(4, 8); 1854 view()->OnSetEditableSelectionOffsets(4, 8);
1824 view()->OnExtendSelectionAndDelete(2, 5); 1855 view()->OnExtendSelectionAndDelete(2, 5);
1825 info = view()->webview()->textInputInfo(); 1856 info = view()->webview()->textInputInfo();
1826 EXPECT_EQ("abuvwxyz", info.value); 1857 EXPECT_EQ("abuvwxyz", info.value);
1827 EXPECT_EQ(2, info.selectionStart); 1858 EXPECT_EQ(2, info.selectionStart);
1828 EXPECT_EQ(2, info.selectionEnd); 1859 EXPECT_EQ(2, info.selectionEnd);
1829 } 1860 }
1830 1861
1831 } // namespace content 1862 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/url_constants.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698