| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/captive_portal/captive_portal_service.h" | 9 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void SimulateSuccess(const GURL& url, | 88 void SimulateSuccess(const GURL& url, |
| 89 content::RenderViewHost* render_view_host) { | 89 content::RenderViewHost* render_view_host) { |
| 90 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); | 90 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); |
| 91 tab_helper().DidStartProvisionalLoadForFrame( | 91 tab_helper().DidStartProvisionalLoadForFrame( |
| 92 render_view_host->GetMainFrame(), url, false, false); | 92 render_view_host->GetMainFrame(), url, false, false); |
| 93 | 93 |
| 94 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 94 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 95 tab_helper().DidCommitProvisionalLoadForFrame( | 95 tab_helper().DidCommitProvisionalLoadForFrame( |
| 96 render_view_host->GetMainFrame(), | 96 render_view_host->GetMainFrame(), |
| 97 url, | 97 url, |
| 98 false, // url_is_unreachable |
| 98 ui::PAGE_TRANSITION_LINK); | 99 ui::PAGE_TRANSITION_LINK); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // Simulates a connection timeout while requesting |url|. | 102 // Simulates a connection timeout while requesting |url|. |
| 102 void SimulateTimeout(const GURL& url, | 103 void SimulateTimeout(const GURL& url, |
| 103 content::RenderViewHost* render_view_host) { | 104 content::RenderViewHost* render_view_host) { |
| 104 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); | 105 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); |
| 105 tab_helper().DidStartProvisionalLoadForFrame( | 106 tab_helper().DidStartProvisionalLoadForFrame( |
| 106 render_view_host->GetMainFrame(), url, false, false); | 107 render_view_host->GetMainFrame(), url, false, false); |
| 107 | 108 |
| 108 tab_helper().DidFailProvisionalLoad(render_view_host->GetMainFrame(), | 109 tab_helper().DidFailProvisionalLoad(render_view_host->GetMainFrame(), |
| 109 url, | 110 url, |
| 110 net::ERR_TIMED_OUT, | 111 net::ERR_TIMED_OUT, |
| 111 base::string16()); | 112 base::string16()); |
| 112 | 113 |
| 113 // Provisional load starts for the error page. | 114 // Provisional load starts for the error page. |
| 114 tab_helper().DidStartProvisionalLoadForFrame( | 115 tab_helper().DidStartProvisionalLoadForFrame( |
| 115 render_view_host->GetMainFrame(), GURL(kErrorPageUrl), true, false); | 116 render_view_host->GetMainFrame(), GURL(kErrorPageUrl), true, false); |
| 116 | 117 |
| 117 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); | 118 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); |
| 118 tab_helper().DidCommitProvisionalLoadForFrame( | 119 tab_helper().DidCommitProvisionalLoadForFrame( |
| 119 render_view_host->GetMainFrame(), | 120 render_view_host->GetMainFrame(), |
| 120 GURL(kErrorPageUrl), | 121 GURL(kErrorPageUrl), |
| 122 false, // url_is_unreachable |
| 121 ui::PAGE_TRANSITION_LINK); | 123 ui::PAGE_TRANSITION_LINK); |
| 122 } | 124 } |
| 123 | 125 |
| 124 // Simulates an abort while requesting |url|. | 126 // Simulates an abort while requesting |url|. |
| 125 void SimulateAbort(const GURL& url, | 127 void SimulateAbort(const GURL& url, |
| 126 content::RenderViewHost* render_view_host, | 128 content::RenderViewHost* render_view_host, |
| 127 NavigationType navigation_type) { | 129 NavigationType navigation_type) { |
| 128 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); | 130 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); |
| 129 tab_helper().DidStartProvisionalLoadForFrame( | 131 tab_helper().DidStartProvisionalLoadForFrame( |
| 130 render_view_host->GetMainFrame(), url, false, false); | 132 render_view_host->GetMainFrame(), url, false, false); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); | 262 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); |
| 261 | 263 |
| 262 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 264 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 263 // Provisional load starts for the error page. | 265 // Provisional load starts for the error page. |
| 264 tab_helper().DidStartProvisionalLoadForFrame( | 266 tab_helper().DidStartProvisionalLoadForFrame( |
| 265 main_render_frame1(), GURL(kErrorPageUrl), true, false); | 267 main_render_frame1(), GURL(kErrorPageUrl), true, false); |
| 266 | 268 |
| 267 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 269 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 268 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), | 270 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 269 GURL(kErrorPageUrl), | 271 GURL(kErrorPageUrl), |
| 272 false, // url_is_unreachable |
| 270 ui::PAGE_TRANSITION_LINK); | 273 ui::PAGE_TRANSITION_LINK); |
| 271 tab_helper().DidStopLoading(render_view_host1()); | 274 tab_helper().DidStopLoading(render_view_host1()); |
| 272 } | 275 } |
| 273 | 276 |
| 274 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { | 277 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { |
| 275 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); | 278 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); |
| 276 tab_helper().DidStopLoading(render_view_host1()); | 279 tab_helper().DidStopLoading(render_view_host1()); |
| 277 EXPECT_FALSE(tab_helper().IsLoginTab()); | 280 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 278 } | 281 } |
| 279 | 282 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 base::string16()); | 363 base::string16()); |
| 361 | 364 |
| 362 // The provisional load starts for the error page for the cross-process | 365 // The provisional load starts for the error page for the cross-process |
| 363 // navigation. | 366 // navigation. |
| 364 tab_helper().DidStartProvisionalLoadForFrame( | 367 tab_helper().DidStartProvisionalLoadForFrame( |
| 365 main_render_frame2(), GURL(kErrorPageUrl), true, false); | 368 main_render_frame2(), GURL(kErrorPageUrl), true, false); |
| 366 | 369 |
| 367 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1); | 370 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1); |
| 368 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame2(), | 371 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame2(), |
| 369 GURL(kErrorPageUrl), | 372 GURL(kErrorPageUrl), |
| 373 false, // url_is_unreachable |
| 370 ui::PAGE_TRANSITION_TYPED); | 374 ui::PAGE_TRANSITION_TYPED); |
| 371 } | 375 } |
| 372 | 376 |
| 373 // Similar to the above test, except the original RenderViewHost manages to | 377 // Similar to the above test, except the original RenderViewHost manages to |
| 374 // commit before its navigation is aborted. | 378 // commit before its navigation is aborted. |
| 375 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) { | 379 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) { |
| 376 GURL same_site_url = GURL(kHttpUrl); | 380 GURL same_site_url = GURL(kHttpUrl); |
| 377 GURL cross_process_url = GURL(kHttpsUrl2); | 381 GURL cross_process_url = GURL(kHttpsUrl2); |
| 378 | 382 |
| 379 // A same-site load for the original RenderViewHost starts. | 383 // A same-site load for the original RenderViewHost starts. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 395 tab_helper().DidFailProvisionalLoad(main_render_frame2(), | 399 tab_helper().DidFailProvisionalLoad(main_render_frame2(), |
| 396 cross_process_url, | 400 cross_process_url, |
| 397 net::ERR_FAILED, | 401 net::ERR_FAILED, |
| 398 base::string16()); | 402 base::string16()); |
| 399 | 403 |
| 400 // The same-site navigation succeeds. | 404 // The same-site navigation succeeds. |
| 401 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); | 405 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); |
| 402 EXPECT_CALL(mock_reloader(), | 406 EXPECT_CALL(mock_reloader(), |
| 403 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); | 407 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); |
| 404 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 408 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 405 tab_helper().DidCommitProvisionalLoadForFrame( | 409 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 406 main_render_frame1(), same_site_url, ui::PAGE_TRANSITION_LINK); | 410 same_site_url, |
| 411 false, // url_is_unreachable |
| 412 ui::PAGE_TRANSITION_LINK); |
| 407 } | 413 } |
| 408 | 414 |
| 409 // Simulates navigations for a number of subframes, and makes sure no | 415 // Simulates navigations for a number of subframes, and makes sure no |
| 410 // CaptivePortalTabHelper function is called. | 416 // CaptivePortalTabHelper function is called. |
| 411 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) { | 417 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) { |
| 412 GURL url = GURL(kHttpsUrl); | 418 GURL url = GURL(kHttpsUrl); |
| 413 | 419 |
| 414 content::RenderFrameHostTester* render_frame_host_tester = | 420 content::RenderFrameHostTester* render_frame_host_tester = |
| 415 content::RenderFrameHostTester::For(main_render_frame1()); | 421 content::RenderFrameHostTester::For(main_render_frame1()); |
| 416 content::RenderFrameHost* subframe1 = | 422 content::RenderFrameHost* subframe1 = |
| 417 render_frame_host_tester->AppendChild("subframe1"); | 423 render_frame_host_tester->AppendChild("subframe1"); |
| 418 | 424 |
| 419 // Normal load. | 425 // Normal load. |
| 420 tab_helper().DidStartProvisionalLoadForFrame(subframe1, url, false, false); | 426 tab_helper().DidStartProvisionalLoadForFrame(subframe1, url, false, false); |
| 421 tab_helper().DidCommitProvisionalLoadForFrame( | 427 tab_helper().DidCommitProvisionalLoadForFrame(subframe1, |
| 422 subframe1, url, ui::PAGE_TRANSITION_LINK); | 428 url, |
| 429 false, // url_is_unreachable |
| 430 ui::PAGE_TRANSITION_LINK); |
| 423 | 431 |
| 424 // Timeout. | 432 // Timeout. |
| 425 content::RenderFrameHost* subframe2 = | 433 content::RenderFrameHost* subframe2 = |
| 426 render_frame_host_tester->AppendChild("subframe2"); | 434 render_frame_host_tester->AppendChild("subframe2"); |
| 427 tab_helper().DidStartProvisionalLoadForFrame(subframe2, url, false, false); | 435 tab_helper().DidStartProvisionalLoadForFrame(subframe2, url, false, false); |
| 428 tab_helper().DidFailProvisionalLoad( | 436 tab_helper().DidFailProvisionalLoad( |
| 429 subframe2, url, net::ERR_TIMED_OUT, base::string16()); | 437 subframe2, url, net::ERR_TIMED_OUT, base::string16()); |
| 430 tab_helper().DidStartProvisionalLoadForFrame(subframe2, url, true, false); | 438 tab_helper().DidStartProvisionalLoadForFrame(subframe2, url, true, false); |
| 431 tab_helper().DidFailProvisionalLoad( | 439 tab_helper().DidFailProvisionalLoad( |
| 432 subframe2, url, net::ERR_ABORTED, base::string16()); | 440 subframe2, url, net::ERR_ABORTED, base::string16()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 461 tab_helper().DidFailProvisionalLoad( | 469 tab_helper().DidFailProvisionalLoad( |
| 462 subframe, url, net::ERR_TIMED_OUT, base::string16()); | 470 subframe, url, net::ERR_TIMED_OUT, base::string16()); |
| 463 | 471 |
| 464 // Provisional load starts for the error pages. | 472 // Provisional load starts for the error pages. |
| 465 tab_helper().DidStartProvisionalLoadForFrame( | 473 tab_helper().DidStartProvisionalLoadForFrame( |
| 466 main_render_frame1(), url, true, false); | 474 main_render_frame1(), url, true, false); |
| 467 tab_helper().DidStartProvisionalLoadForFrame(subframe, url, true, false); | 475 tab_helper().DidStartProvisionalLoadForFrame(subframe, url, true, false); |
| 468 | 476 |
| 469 // Error page load finishes. | 477 // Error page load finishes. |
| 470 tab_helper().DidCommitProvisionalLoadForFrame( | 478 tab_helper().DidCommitProvisionalLoadForFrame( |
| 471 subframe, url, ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 479 subframe, |
| 480 url, |
| 481 false, // url_is_unreachable |
| 482 ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 472 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); | 483 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); |
| 473 tab_helper().DidCommitProvisionalLoadForFrame( | 484 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 474 main_render_frame1(), url, ui::PAGE_TRANSITION_LINK); | 485 url, |
| 486 false, // url_is_unreachable |
| 487 ui::PAGE_TRANSITION_LINK); |
| 475 } | 488 } |
| 476 | 489 |
| 477 // Simulates an HTTP to HTTPS redirect, which then times out. | 490 // Simulates an HTTP to HTTPS redirect, which then times out. |
| 478 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { | 491 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { |
| 479 GURL http_url(kHttpUrl); | 492 GURL http_url(kHttpUrl); |
| 480 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 493 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 481 tab_helper().DidStartProvisionalLoadForFrame( | 494 tab_helper().DidStartProvisionalLoadForFrame( |
| 482 main_render_frame1(), http_url, false, false); | 495 main_render_frame1(), http_url, false, false); |
| 483 | 496 |
| 484 GURL https_url(kHttpsUrl); | 497 GURL https_url(kHttpsUrl); |
| 485 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); | 498 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); |
| 486 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, | 499 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, |
| 487 https_url, | 500 https_url, |
| 488 render_view_host1()->GetProcess()->GetID()); | 501 render_view_host1()->GetProcess()->GetID()); |
| 489 | 502 |
| 490 tab_helper().DidFailProvisionalLoad(main_render_frame1(), | 503 tab_helper().DidFailProvisionalLoad(main_render_frame1(), |
| 491 https_url, | 504 https_url, |
| 492 net::ERR_TIMED_OUT, | 505 net::ERR_TIMED_OUT, |
| 493 base::string16()); | 506 base::string16()); |
| 494 | 507 |
| 495 // Provisional load starts for the error page. | 508 // Provisional load starts for the error page. |
| 496 tab_helper().DidStartProvisionalLoadForFrame( | 509 tab_helper().DidStartProvisionalLoadForFrame( |
| 497 main_render_frame1(), GURL(kErrorPageUrl), true, false); | 510 main_render_frame1(), GURL(kErrorPageUrl), true, false); |
| 498 | 511 |
| 499 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); | 512 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); |
| 500 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), | 513 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 501 GURL(kErrorPageUrl), | 514 GURL(kErrorPageUrl), |
| 515 false, // url_is_unreachable |
| 502 ui::PAGE_TRANSITION_LINK); | 516 ui::PAGE_TRANSITION_LINK); |
| 503 } | 517 } |
| 504 | 518 |
| 505 // Simulates an HTTPS to HTTP redirect. | 519 // Simulates an HTTPS to HTTP redirect. |
| 506 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) { | 520 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) { |
| 507 GURL https_url(kHttpsUrl); | 521 GURL https_url(kHttpsUrl); |
| 508 EXPECT_CALL(mock_reloader(), | 522 EXPECT_CALL(mock_reloader(), |
| 509 OnLoadStart(https_url.SchemeIsSecure())).Times(1); | 523 OnLoadStart(https_url.SchemeIsSecure())).Times(1); |
| 510 tab_helper().DidStartProvisionalLoadForFrame( | 524 tab_helper().DidStartProvisionalLoadForFrame( |
| 511 main_render_frame1(), https_url, false, false); | 525 main_render_frame1(), https_url, false, false); |
| 512 | 526 |
| 513 GURL http_url(kHttpUrl); | 527 GURL http_url(kHttpUrl); |
| 514 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); | 528 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); |
| 515 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, http_url, | 529 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, http_url, |
| 516 render_view_host1()->GetProcess()->GetID()); | 530 render_view_host1()->GetProcess()->GetID()); |
| 517 | 531 |
| 518 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 532 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 519 tab_helper().DidCommitProvisionalLoadForFrame( | 533 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 520 main_render_frame1(), http_url, ui::PAGE_TRANSITION_LINK); | 534 http_url, |
| 535 false, // url_is_unreachable |
| 536 ui::PAGE_TRANSITION_LINK); |
| 521 } | 537 } |
| 522 | 538 |
| 523 // Simulates an HTTPS to HTTPS redirect. | 539 // Simulates an HTTPS to HTTPS redirect. |
| 524 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) { | 540 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) { |
| 525 GURL http_url(kHttpUrl); | 541 GURL http_url(kHttpUrl); |
| 526 EXPECT_CALL(mock_reloader(), | 542 EXPECT_CALL(mock_reloader(), |
| 527 OnLoadStart(http_url.SchemeIsSecure())).Times(1); | 543 OnLoadStart(http_url.SchemeIsSecure())).Times(1); |
| 528 tab_helper().DidStartProvisionalLoadForFrame( | 544 tab_helper().DidStartProvisionalLoadForFrame( |
| 529 main_render_frame1(), http_url, false, false); | 545 main_render_frame1(), http_url, false, false); |
| 530 | 546 |
| 531 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); | 547 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); |
| 532 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, http_url, | 548 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, http_url, |
| 533 render_view_host1()->GetProcess()->GetID()); | 549 render_view_host1()->GetProcess()->GetID()); |
| 534 | 550 |
| 535 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 551 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 536 tab_helper().DidCommitProvisionalLoadForFrame( | 552 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 537 main_render_frame1(), http_url, ui::PAGE_TRANSITION_LINK); | 553 http_url, |
| 554 false /* url_is_unreachable */, |
| 555 ui::PAGE_TRANSITION_LINK); |
| 538 } | 556 } |
| 539 | 557 |
| 540 // Tests that a subframe redirect doesn't reset the timer to kick off a captive | 558 // Tests that a subframe redirect doesn't reset the timer to kick off a captive |
| 541 // portal probe for the main frame if the main frame request is taking too long. | 559 // portal probe for the main frame if the main frame request is taking too long. |
| 542 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) { | 560 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) { |
| 543 GURL http_url(kHttpUrl); | 561 GURL http_url(kHttpUrl); |
| 544 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 562 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 545 tab_helper().DidStartProvisionalLoadForFrame( | 563 tab_helper().DidStartProvisionalLoadForFrame( |
| 546 main_render_frame1(), http_url, false, false); | 564 main_render_frame1(), http_url, false, false); |
| 547 | 565 |
| 548 GURL https_url(kHttpsUrl); | 566 GURL https_url(kHttpsUrl); |
| 549 OnRedirect(content::RESOURCE_TYPE_SUB_FRAME, | 567 OnRedirect(content::RESOURCE_TYPE_SUB_FRAME, |
| 550 https_url, | 568 https_url, |
| 551 render_view_host1()->GetProcess()->GetID()); | 569 render_view_host1()->GetProcess()->GetID()); |
| 552 | 570 |
| 553 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 571 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 554 tab_helper().DidCommitProvisionalLoadForFrame( | 572 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 555 main_render_frame1(), GURL(kErrorPageUrl), ui::PAGE_TRANSITION_LINK); | 573 GURL(kErrorPageUrl), |
| 574 false, // url_is_unreachable |
| 575 ui::PAGE_TRANSITION_LINK); |
| 556 } | 576 } |
| 557 | 577 |
| 558 // Simulates a redirect, for another RenderViewHost. | 578 // Simulates a redirect, for another RenderViewHost. |
| 559 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) { | 579 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) { |
| 560 GURL http_url(kHttpUrl); | 580 GURL http_url(kHttpUrl); |
| 561 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 581 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 562 tab_helper().DidStartProvisionalLoadForFrame( | 582 tab_helper().DidStartProvisionalLoadForFrame( |
| 563 main_render_frame1(), http_url, false, false); | 583 main_render_frame1(), http_url, false, false); |
| 564 | 584 |
| 565 // Another RenderViewHost sees a redirect. None of the reloader's functions | 585 // Another RenderViewHost sees a redirect. None of the reloader's functions |
| 566 // should be called. | 586 // should be called. |
| 567 GURL https_url(kHttpsUrl); | 587 GURL https_url(kHttpsUrl); |
| 568 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, | 588 OnRedirect(content::RESOURCE_TYPE_MAIN_FRAME, |
| 569 https_url, | 589 https_url, |
| 570 render_view_host2()->GetProcess()->GetID()); | 590 render_view_host2()->GetProcess()->GetID()); |
| 571 | 591 |
| 572 tab_helper().DidFailProvisionalLoad(main_render_frame1(), | 592 tab_helper().DidFailProvisionalLoad(main_render_frame1(), |
| 573 https_url, | 593 https_url, |
| 574 net::ERR_TIMED_OUT, | 594 net::ERR_TIMED_OUT, |
| 575 base::string16()); | 595 base::string16()); |
| 576 | 596 |
| 577 // Provisional load starts for the error page. | 597 // Provisional load starts for the error page. |
| 578 tab_helper().DidStartProvisionalLoadForFrame( | 598 tab_helper().DidStartProvisionalLoadForFrame( |
| 579 main_render_frame1(), GURL(kErrorPageUrl), true, false); | 599 main_render_frame1(), GURL(kErrorPageUrl), true, false); |
| 580 | 600 |
| 581 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); | 601 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); |
| 582 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), | 602 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 583 GURL(kErrorPageUrl), | 603 GURL(kErrorPageUrl), |
| 604 false, // url_is_unreachable |
| 584 ui::PAGE_TRANSITION_LINK); | 605 ui::PAGE_TRANSITION_LINK); |
| 585 } | 606 } |
| 586 | 607 |
| 587 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) { | 608 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) { |
| 588 EXPECT_FALSE(tab_helper().IsLoginTab()); | 609 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 589 SetIsLoginTab(); | 610 SetIsLoginTab(); |
| 590 EXPECT_TRUE(tab_helper().IsLoginTab()); | 611 EXPECT_TRUE(tab_helper().IsLoginTab()); |
| 591 | 612 |
| 592 ObservePortalResult(captive_portal::RESULT_INTERNET_CONNECTED, | 613 ObservePortalResult(captive_portal::RESULT_INTERNET_CONNECTED, |
| 593 captive_portal::RESULT_INTERNET_CONNECTED); | 614 captive_portal::RESULT_INTERNET_CONNECTED); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 EXPECT_FALSE(tab_helper().IsLoginTab()); | 653 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 633 | 654 |
| 634 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 655 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 635 captive_portal::RESULT_NO_RESPONSE); | 656 captive_portal::RESULT_NO_RESPONSE); |
| 636 EXPECT_FALSE(tab_helper().IsLoginTab()); | 657 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 637 | 658 |
| 638 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 659 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 639 captive_portal::RESULT_INTERNET_CONNECTED); | 660 captive_portal::RESULT_INTERNET_CONNECTED); |
| 640 EXPECT_FALSE(tab_helper().IsLoginTab()); | 661 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 641 } | 662 } |
| OLD | NEW |