| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" |
| 44 #include "content/test/test_content_browser_client.h" | 44 #include "content/test/test_content_browser_client.h" |
| 45 #include "content/test/test_content_client.h" | 45 #include "content/test/test_content_client.h" |
| 46 #include "content/test/test_render_frame_host.h" | 46 #include "content/test/test_render_frame_host.h" |
| 47 #include "content/test/test_render_view_host.h" | 47 #include "content/test/test_render_view_host.h" |
| 48 #include "content/test/test_web_contents.h" | 48 #include "content/test/test_web_contents.h" |
| 49 #include "net/base/test_data_directory.h" | 49 #include "net/base/test_data_directory.h" |
| 50 #include "net/test/cert_test_util.h" | 50 #include "net/test/cert_test_util.h" |
| 51 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
| 52 #include "third_party/skia/include/core/SkColor.h" | 52 #include "third_party/skia/include/core/SkColor.h" |
| 53 #include "url/url_constants.h" |
| 53 | 54 |
| 54 namespace content { | 55 namespace content { |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 57 class TestInterstitialPage; | 58 class TestInterstitialPage; |
| 58 | 59 |
| 59 class TestInterstitialPageDelegate : public InterstitialPageDelegate { | 60 class TestInterstitialPageDelegate : public InterstitialPageDelegate { |
| 60 public: | 61 public: |
| 61 explicit TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page) | 62 explicit TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page) |
| 62 : interstitial_page_(interstitial_page) {} | 63 : interstitial_page_(interstitial_page) {} |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 EXPECT_EQ( | 481 EXPECT_EQ( |
| 481 instance1, | 482 instance1, |
| 482 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> | 483 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> |
| 483 site_instance()); | 484 site_instance()); |
| 484 } | 485 } |
| 485 | 486 |
| 486 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. | 487 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. |
| 487 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { | 488 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { |
| 488 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. | 489 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. |
| 489 const GURL url(std::string("http://example.org/").append( | 490 const GURL url(std::string("http://example.org/").append( |
| 490 kMaxURLChars + 1, 'a')); | 491 url::kMaxURLChars + 1, 'a')); |
| 491 | 492 |
| 492 controller().LoadURL( | 493 controller().LoadURL( |
| 493 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string()); | 494 url, Referrer(), ui::PAGE_TRANSITION_GENERATED, std::string()); |
| 494 EXPECT_EQ(nullptr, controller().GetPendingEntry()); | 495 EXPECT_EQ(nullptr, controller().GetPendingEntry()); |
| 495 } | 496 } |
| 496 | 497 |
| 497 // Test that we reject NavigateToEntry if the url is invalid. | 498 // Test that we reject NavigateToEntry if the url is invalid. |
| 498 TEST_F(WebContentsImplTest, NavigateToInvalidURL) { | 499 TEST_F(WebContentsImplTest, NavigateToInvalidURL) { |
| 499 // Invalid URLs should not trigger a navigation. | 500 // Invalid URLs should not trigger a navigation. |
| 500 const GURL invalid_url("view-source:http://example.org/%00"); | 501 const GURL invalid_url("view-source:http://example.org/%00"); |
| (...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 backend->AllowCertForHost(*cert, test_url.host(), 1); | 3379 backend->AllowCertForHost(*cert, test_url.host(), 1); |
| 3379 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3380 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3380 | 3381 |
| 3381 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", | 3382 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", |
| 3382 RESOURCE_TYPE_MAIN_FRAME); | 3383 RESOURCE_TYPE_MAIN_FRAME); |
| 3383 | 3384 |
| 3384 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3385 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3385 } | 3386 } |
| 3386 | 3387 |
| 3387 } // namespace content | 3388 } // namespace content |
| OLD | NEW |