| 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 "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 14 matching lines...) Expand all Loading... |
| 25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 27 #include "content/public/browser/render_widget_host_view.h" | 27 #include "content/public/browser/render_widget_host_view.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
| 30 #include "content/public/browser/web_ui_controller.h" | 30 #include "content/public/browser/web_ui_controller.h" |
| 31 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
| 32 #include "content/public/common/content_constants.h" | 32 #include "content/public/common/content_constants.h" |
| 33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 35 #include "content/public/common/url_utils.h" | |
| 36 #include "content/public/test/mock_render_process_host.h" | 35 #include "content/public/test/mock_render_process_host.h" |
| 37 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
| 38 #include "content/test/test_content_browser_client.h" | 37 #include "content/test/test_content_browser_client.h" |
| 39 #include "content/test/test_content_client.h" | 38 #include "content/test/test_content_client.h" |
| 40 #include "content/test/test_render_frame_host.h" | 39 #include "content/test/test_render_frame_host.h" |
| 41 #include "content/test/test_render_view_host.h" | 40 #include "content/test/test_render_view_host.h" |
| 42 #include "content/test/test_web_contents.h" | 41 #include "content/test/test_web_contents.h" |
| 43 #include "net/base/test_data_directory.h" | 42 #include "net/base/test_data_directory.h" |
| 44 #include "net/test/cert_test_util.h" | 43 #include "net/test/cert_test_util.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 EXPECT_EQ( | 461 EXPECT_EQ( |
| 463 instance1, | 462 instance1, |
| 464 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> | 463 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> |
| 465 site_instance()); | 464 site_instance()); |
| 466 } | 465 } |
| 467 | 466 |
| 468 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. | 467 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. |
| 469 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { | 468 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { |
| 470 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. | 469 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. |
| 471 const GURL url(std::string("http://example.org/").append( | 470 const GURL url(std::string("http://example.org/").append( |
| 472 GetMaxURLChars() + 1, 'a')); | 471 kMaxURLChars + 1, 'a')); |
| 473 | 472 |
| 474 controller().LoadURL( | 473 controller().LoadURL( |
| 475 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string()); | 474 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string()); |
| 476 EXPECT_EQ(nullptr, controller().GetPendingEntry()); | 475 EXPECT_EQ(nullptr, controller().GetPendingEntry()); |
| 477 } | 476 } |
| 478 | 477 |
| 479 // Test that we reject NavigateToEntry if the url is invalid. | 478 // Test that we reject NavigateToEntry if the url is invalid. |
| 480 TEST_F(WebContentsImplTest, NavigateToInvalidURL) { | 479 TEST_F(WebContentsImplTest, NavigateToInvalidURL) { |
| 481 // Invalid URLs should not trigger a navigation. | 480 // Invalid URLs should not trigger a navigation. |
| 482 const GURL invalid_url("view-source:http://example.org/%00"); | 481 const GURL invalid_url("view-source:http://example.org/%00"); |
| (...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 backend->AllowCertForHost(*cert, test_url.host(), 1); | 3365 backend->AllowCertForHost(*cert, test_url.host(), 1); |
| 3367 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3366 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3368 | 3367 |
| 3369 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", | 3368 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", |
| 3370 RESOURCE_TYPE_MAIN_FRAME); | 3369 RESOURCE_TYPE_MAIN_FRAME); |
| 3371 | 3370 |
| 3372 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3371 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3373 } | 3372 } |
| 3374 | 3373 |
| 3375 } // namespace content | 3374 } // namespace content |
| OLD | NEW |