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

Side by Side Diff: chrome/browser/net/net_error_tab_helper_unittest.cc

Issue 1276843006: Don't run platform diagnostics tool on invalid URLs from the renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/net/net_error_tab_helper.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/net/net_error_tab_helper.h" 5 #include "chrome/browser/net/net_error_tab_helper.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 #include "components/error_page/common/net_error_info.h" 9 #include "components/error_page/common/net_error_info.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // diagnostics tool. 414 // diagnostics tool.
415 TEST_F(NetErrorTabHelperTest, SanitizeDiagnosticsUrl) { 415 TEST_F(NetErrorTabHelperTest, SanitizeDiagnosticsUrl) {
416 content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); 416 content::RenderFrameHost* rfh = web_contents()->GetMainFrame();
417 rfh->OnMessageReceived(ChromeViewHostMsg_RunNetworkDiagnostics( 417 rfh->OnMessageReceived(ChromeViewHostMsg_RunNetworkDiagnostics(
418 rfh->GetRoutingID(), 418 rfh->GetRoutingID(),
419 GURL("http://foo:bar@somewhere:123/hats?for#goats"))); 419 GURL("http://foo:bar@somewhere:123/hats?for#goats")));
420 EXPECT_EQ(GURL("http://somewhere:123/"), 420 EXPECT_EQ(GURL("http://somewhere:123/"),
421 tab_helper()->network_diagnostics_url()); 421 tab_helper()->network_diagnostics_url());
422 } 422 }
423 423
424 // Makes sure that diagnostics aren't run on URLS with non-HTTP/HTTPS schemes. 424 // Makes sure that diagnostics aren't run on invalid URLs or URLs with
425 // non-HTTP/HTTPS schemes.
425 TEST_F(NetErrorTabHelperTest, NoDiagnosticsForNonHttpSchemes) { 426 TEST_F(NetErrorTabHelperTest, NoDiagnosticsForNonHttpSchemes) {
426 const char* kUrls[] = { 427 const char* kUrls[] = {
428 "",
429 "http",
427 "file:///blah/blah", 430 "file:///blah/blah",
428 "chrome://blah/", 431 "chrome://blah/",
429 "about:blank", 432 "about:blank",
430 "file://foo/bar", 433 "file://foo/bar",
431 }; 434 };
432 435
433 for (const char* url : kUrls) { 436 for (const char* url : kUrls) {
434 content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); 437 content::RenderFrameHost* rfh = web_contents()->GetMainFrame();
435 rfh->OnMessageReceived(ChromeViewHostMsg_RunNetworkDiagnostics( 438 rfh->OnMessageReceived(ChromeViewHostMsg_RunNetworkDiagnostics(
436 rfh->GetRoutingID(), GURL(url))); 439 rfh->GetRoutingID(), GURL(url)));
437 EXPECT_EQ(GURL(""), tab_helper()->network_diagnostics_url()); 440 EXPECT_EQ(GURL(""), tab_helper()->network_diagnostics_url());
438 } 441 }
439 } 442 }
OLDNEW
« no previous file with comments | « chrome/browser/net/net_error_tab_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698