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