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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1497743005: Allow huge data: URIs only via WebView.loadDataWithBaseUrl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the test Created 5 years 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/frame_host/cross_site_transferring_request.h" 8 #include "content/browser/frame_host/cross_site_transferring_request.h"
9 #include "content/browser/frame_host/interstitial_page_impl.h" 9 #include "content/browser/frame_host/interstitial_page_impl.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 15 matching lines...) Expand all
26 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/render_widget_host_view.h" 28 #include "content/public/browser/render_widget_host_view.h"
29 #include "content/public/browser/web_contents_delegate.h" 29 #include "content/public/browser/web_contents_delegate.h"
30 #include "content/public/browser/web_contents_observer.h" 30 #include "content/public/browser/web_contents_observer.h"
31 #include "content/public/browser/web_ui_controller.h" 31 #include "content/public/browser/web_ui_controller.h"
32 #include "content/public/common/bindings_policy.h" 32 #include "content/public/common/bindings_policy.h"
33 #include "content/public/common/content_constants.h" 33 #include "content/public/common/content_constants.h"
34 #include "content/public/common/content_switches.h" 34 #include "content/public/common/content_switches.h"
35 #include "content/public/common/url_constants.h" 35 #include "content/public/common/url_constants.h"
36 #include "content/public/common/url_utils.h"
37 #include "content/public/test/mock_render_process_host.h" 36 #include "content/public/test/mock_render_process_host.h"
38 #include "content/public/test/test_utils.h" 37 #include "content/public/test/test_utils.h"
39 #include "content/test/test_content_browser_client.h" 38 #include "content/test/test_content_browser_client.h"
40 #include "content/test/test_content_client.h" 39 #include "content/test/test_content_client.h"
41 #include "content/test/test_render_frame_host.h" 40 #include "content/test/test_render_frame_host.h"
42 #include "content/test/test_render_view_host.h" 41 #include "content/test/test_render_view_host.h"
43 #include "content/test/test_web_contents.h" 42 #include "content/test/test_web_contents.h"
44 #include "net/base/test_data_directory.h" 43 #include "net/base/test_data_directory.h"
45 #include "net/test/cert_test_util.h" 44 #include "net/test/cert_test_util.h"
46 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 EXPECT_EQ( 474 EXPECT_EQ(
476 instance1, 475 instance1,
477 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> 476 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())->
478 site_instance()); 477 site_instance());
479 } 478 }
480 479
481 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. 480 // Test that we reject NavigateToEntry if the url is over kMaxURLChars.
482 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { 481 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) {
483 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. 482 // Construct a URL that's kMaxURLChars + 1 long of all 'a's.
484 const GURL url(std::string("http://example.org/").append( 483 const GURL url(std::string("http://example.org/").append(
485 GetMaxURLChars() + 1, 'a')); 484 kMaxURLChars + 1, 'a'));
486 485
487 controller().LoadURL( 486 controller().LoadURL(
488 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string()); 487 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string());
489 EXPECT_EQ(nullptr, controller().GetPendingEntry()); 488 EXPECT_EQ(nullptr, controller().GetPendingEntry());
490 } 489 }
491 490
492 // Test that we reject NavigateToEntry if the url is invalid. 491 // Test that we reject NavigateToEntry if the url is invalid.
493 TEST_F(WebContentsImplTest, NavigateToInvalidURL) { 492 TEST_F(WebContentsImplTest, NavigateToInvalidURL) {
494 // Invalid URLs should not trigger a navigation. 493 // Invalid URLs should not trigger a navigation.
495 const GURL invalid_url("view-source:http://example.org/%00"); 494 const GURL invalid_url("view-source:http://example.org/%00");
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 backend->AllowCertForHost(*cert, test_url.host(), 1); 3378 backend->AllowCertForHost(*cert, test_url.host(), 1);
3380 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3379 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3381 3380
3382 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", 3381 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type",
3383 RESOURCE_TYPE_MAIN_FRAME); 3382 RESOURCE_TYPE_MAIN_FRAME);
3384 3383
3385 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3384 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3386 } 3385 }
3387 3386
3388 } // namespace content 3387 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | content/child/service_worker/service_worker_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698