Chromium Code Reviews| 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 "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "chrome/browser/captive_portal/captive_portal_service.h" | 12 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 12 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 13 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 18 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/browser_side_navigation_policy.h" | 23 #include "content/public/common/browser_side_navigation_policy.h" |
| 24 #include "content/public/common/content_switches.h" | |
| 23 #include "content/public/test/test_renderer_host.h" | 25 #include "content/public/test/test_renderer_host.h" |
| 24 #include "content/public/test/web_contents_tester.h" | 26 #include "content/public/test/web_contents_tester.h" |
| 25 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 30 |
| 29 using captive_portal::CaptivePortalResult; | 31 using captive_portal::CaptivePortalResult; |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 content::RenderFrameHostTester::For(subframe3); | 375 content::RenderFrameHostTester::For(subframe3); |
| 374 subframe_tester3->SimulateNavigationStart(url); | 376 subframe_tester3->SimulateNavigationStart(url); |
| 375 subframe_tester3->SimulateNavigationError(url, net::ERR_ABORTED); | 377 subframe_tester3->SimulateNavigationError(url, net::ERR_ABORTED); |
| 376 subframe_tester3->SimulateNavigationStop(); | 378 subframe_tester3->SimulateNavigationStop(); |
| 377 } | 379 } |
| 378 | 380 |
| 379 // Simulates a subframe erroring out at the same time as a provisional load, | 381 // Simulates a subframe erroring out at the same time as a provisional load, |
| 380 // but with a different error code. Make sure the TabHelper sees the correct | 382 // but with a different error code. Make sure the TabHelper sees the correct |
| 381 // error. | 383 // error. |
| 382 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) { | 384 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) { |
| 385 if (content::IsBrowserSideNavigationEnabled() && | |
| 386 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
|
nasko
2017/03/01 00:24:00
This should be AreAllSitesIsolatedForTesting() ins
jam
2017/03/01 00:58:31
Done.
| |
| 387 switches::kSitePerProcess)) { | |
| 388 // http://crbug.com/674734 Fix this test with PlzNavigate and Site Isolation | |
| 389 return; | |
| 390 } | |
| 383 // URL used by both frames. | 391 // URL used by both frames. |
| 384 GURL url = GURL(kHttpsUrl); | 392 GURL url = GURL(kHttpsUrl); |
| 385 content::RenderFrameHostTester* rfh_tester = | 393 content::RenderFrameHostTester* rfh_tester = |
| 386 content::RenderFrameHostTester::For(main_rfh()); | 394 content::RenderFrameHostTester::For(main_rfh()); |
| 387 content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); | 395 content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); |
| 388 content::RenderFrameHostTester* subframe_tester = | 396 content::RenderFrameHostTester* subframe_tester = |
| 389 content::RenderFrameHostTester::For(subframe); | 397 content::RenderFrameHostTester::For(subframe); |
| 390 | 398 |
| 391 // Loads start. | 399 // Loads start. |
| 392 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) | 400 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) |
| 393 .Times(1); | 401 .Times(1); |
| 394 rfh_tester->SimulateNavigationStart(url); | 402 rfh_tester->SimulateNavigationStart(url); |
| 395 subframe_tester->SimulateNavigationStart(url); | 403 subframe_tester->SimulateNavigationStart(url); |
| 396 | 404 |
| 397 // Loads return errors. | 405 // Loads return errors. |
| 398 rfh_tester->SimulateNavigationError(url, net::ERR_UNEXPECTED); | 406 rfh_tester->SimulateNavigationError(url, net::ERR_UNEXPECTED); |
| 399 subframe_tester->SimulateNavigationError(url, net::ERR_TIMED_OUT); | 407 subframe_tester->SimulateNavigationError(url, net::ERR_TIMED_OUT); |
| 400 | 408 |
| 401 // Error page load finishes. | 409 // Error page load finishes. |
| 402 subframe_tester->SimulateNavigationErrorPageCommit(); | 410 subframe_tester->SimulateNavigationErrorPageCommit(); |
| 403 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); | 411 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); |
| 404 rfh_tester->SimulateNavigationErrorPageCommit(); | 412 rfh_tester->SimulateNavigationErrorPageCommit(); |
| 405 } | 413 } |
| 406 | 414 |
| 407 // Simulates an HTTP to HTTPS redirect, which then times out. | 415 // Simulates an HTTP to HTTPS redirect, which then times out. |
| 408 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { | 416 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { |
| 417 if (content::IsBrowserSideNavigationEnabled() && | |
| 418 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 419 switches::kSitePerProcess)) { | |
| 420 // http://crbug.com/674734 Fix this test with PlzNavigate and Site Isolation | |
| 421 return; | |
| 422 } | |
| 409 GURL http_url(kHttpUrl); | 423 GURL http_url(kHttpUrl); |
| 410 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 424 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 411 content::RenderFrameHostTester* rfh_tester = | 425 content::RenderFrameHostTester* rfh_tester = |
| 412 content::RenderFrameHostTester::For(main_rfh()); | 426 content::RenderFrameHostTester::For(main_rfh()); |
| 413 rfh_tester->SimulateNavigationStart(http_url); | 427 rfh_tester->SimulateNavigationStart(http_url); |
| 414 | 428 |
| 415 GURL https_url(kHttpsUrl); | 429 GURL https_url(kHttpsUrl); |
| 416 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); | 430 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); |
| 417 rfh_tester->SimulateRedirect(https_url); | 431 rfh_tester->SimulateRedirect(https_url); |
| 418 | 432 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 540 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 527 | 541 |
| 528 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 542 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 529 captive_portal::RESULT_NO_RESPONSE); | 543 captive_portal::RESULT_NO_RESPONSE); |
| 530 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 544 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 531 | 545 |
| 532 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 546 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 533 captive_portal::RESULT_INTERNET_CONNECTED); | 547 captive_portal::RESULT_INTERNET_CONNECTED); |
| 534 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 548 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 535 } | 549 } |
| OLD | NEW |