Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc

Issue 11090068: When starting a provisional load include the parent frame ID in the IPC and pass it down the th WCO… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updatess Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 web_contents2_.reset(NULL); 82 web_contents2_.reset(NULL);
83 web_contents1_.reset(NULL); 83 web_contents1_.reset(NULL);
84 TabContentsTestHarness::TearDown(); 84 TabContentsTestHarness::TearDown();
85 } 85 }
86 86
87 // Simulates a successful load of |url|. 87 // Simulates a successful load of |url|.
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 1, true, url, false, render_view_host); 92 1, -1, true, url, false, render_view_host);
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 1, true, url, content::PAGE_TRANSITION_LINK, render_view_host); 96 1, true, url, content::PAGE_TRANSITION_LINK, render_view_host);
97 } 97 }
98 98
99 // Simulates a connection timeout while requesting |url|. 99 // Simulates a connection timeout while requesting |url|.
100 void SimulateTimeout(const GURL& url, 100 void SimulateTimeout(const GURL& url,
101 content::RenderViewHost* render_view_host) { 101 content::RenderViewHost* render_view_host) {
102 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 102 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
103 tab_helper().DidStartProvisionalLoadForFrame( 103 tab_helper().DidStartProvisionalLoadForFrame(
104 1, true, url, false, render_view_host); 104 1, -1, true, url, false, render_view_host);
105 105
106 tab_helper().DidFailProvisionalLoad( 106 tab_helper().DidFailProvisionalLoad(
107 1, true, url, net::ERR_TIMED_OUT, string16(), render_view_host); 107 1, true, url, net::ERR_TIMED_OUT, string16(), render_view_host);
108 108
109 // Provisional load starts for the error page. 109 // Provisional load starts for the error page.
110 tab_helper().DidStartProvisionalLoadForFrame( 110 tab_helper().DidStartProvisionalLoadForFrame(
111 1, true, GURL(kErrorPageUrl), true, render_view_host); 111 1, -1, true, GURL(kErrorPageUrl), true, render_view_host);
112 112
113 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 113 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
114 tab_helper().DidCommitProvisionalLoadForFrame( 114 tab_helper().DidCommitProvisionalLoadForFrame(
115 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 115 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK,
116 render_view_host); 116 render_view_host);
117 } 117 }
118 118
119 // Simulates an abort while requesting |url|. 119 // Simulates an abort while requesting |url|.
120 void SimulateAbort(const GURL& url, 120 void SimulateAbort(const GURL& url,
121 content::RenderViewHost* render_view_host, 121 content::RenderViewHost* render_view_host,
122 NavigationType navigation_type) { 122 NavigationType navigation_type) {
123 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 123 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
124 tab_helper().DidStartProvisionalLoadForFrame( 124 tab_helper().DidStartProvisionalLoadForFrame(
125 1, true, url, false, render_view_host); 125 1, -1, true, url, false, render_view_host);
126 126
127 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 127 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
128 if (navigation_type == kSameProcess) { 128 if (navigation_type == kSameProcess) {
129 tab_helper().DidFailProvisionalLoad( 129 tab_helper().DidFailProvisionalLoad(
130 1, true, url, net::ERR_ABORTED, string16(), render_view_host); 130 1, true, url, net::ERR_ABORTED, string16(), render_view_host);
131 } else { 131 } else {
132 // For interrupted provisional cross-process navigations, the 132 // For interrupted provisional cross-process navigations, the
133 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad 133 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad
134 // notification. 134 // notification.
135 tab_helper().Observe( 135 tab_helper().Observe(
136 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 136 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
137 content::Source<content::RenderViewHost>(render_view_host), 137 content::Source<content::RenderViewHost>(render_view_host),
138 content::NotificationService::NoDetails()); 138 content::NotificationService::NoDetails());
139 } 139 }
140 140
141 // Make sure that above call resulted in abort, for tests that continue 141 // Make sure that above call resulted in abort, for tests that continue
142 // after the abort. 142 // after the abort.
143 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0); 143 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0);
144 } 144 }
145 145
146 // Simulates an abort while loading an error page. 146 // Simulates an abort while loading an error page.
147 void SimulateAbortTimeout(const GURL& url, 147 void SimulateAbortTimeout(const GURL& url,
148 content::RenderViewHost* render_view_host, 148 content::RenderViewHost* render_view_host,
149 NavigationType navigation_type) { 149 NavigationType navigation_type) {
150 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 150 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
151 tab_helper().DidStartProvisionalLoadForFrame( 151 tab_helper().DidStartProvisionalLoadForFrame(
152 1, true, url, false, render_view_host); 152 1, -1, true, url, false, render_view_host);
153 153
154 tab_helper().DidFailProvisionalLoad( 154 tab_helper().DidFailProvisionalLoad(
155 1, true, url, net::ERR_TIMED_OUT, string16(), render_view_host); 155 1, true, url, net::ERR_TIMED_OUT, string16(), render_view_host);
156 156
157 // Start event for the error page. 157 // Start event for the error page.
158 tab_helper().DidStartProvisionalLoadForFrame( 158 tab_helper().DidStartProvisionalLoadForFrame(
159 1, true, url, true, render_view_host); 159 1, -1, true, url, true, render_view_host);
160 160
161 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 161 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
162 if (navigation_type == kSameProcess) { 162 if (navigation_type == kSameProcess) {
163 tab_helper().DidFailProvisionalLoad( 163 tab_helper().DidFailProvisionalLoad(
164 1, true, url, net::ERR_ABORTED, string16(), render_view_host); 164 1, true, url, net::ERR_ABORTED, string16(), render_view_host);
165 } else { 165 } else {
166 // For interrupted provisional cross-process navigations, the 166 // For interrupted provisional cross-process navigations, the
167 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad 167 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad
168 // notification. 168 // notification.
169 tab_helper().Observe( 169 tab_helper().Observe(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 // Same as above, but simulates what happens when the Link Doctor is enabled, 244 // Same as above, but simulates what happens when the Link Doctor is enabled,
245 // which adds another provisional load/commit for the error page, after the 245 // which adds another provisional load/commit for the error page, after the
246 // first two. 246 // first two.
247 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { 247 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) {
248 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); 248 SimulateTimeout(GURL(kHttpUrl), render_view_host1());
249 249
250 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 250 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
251 // Provisional load starts for the error page. 251 // Provisional load starts for the error page.
252 tab_helper().DidStartProvisionalLoadForFrame( 252 tab_helper().DidStartProvisionalLoadForFrame(
253 1, true, GURL(kErrorPageUrl), true, render_view_host1()); 253 1, -1, true, GURL(kErrorPageUrl), true, render_view_host1());
254 254
255 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 255 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
256 tab_helper().DidCommitProvisionalLoadForFrame( 256 tab_helper().DidCommitProvisionalLoadForFrame(
257 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 257 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK,
258 render_view_host1()); 258 render_view_host1());
259 tab_helper().DidStopLoading(render_view_host1()); 259 tab_helper().DidStopLoading(render_view_host1());
260 } 260 }
261 261
262 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { 262 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) {
263 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); 263 SimulateSuccess(GURL(kHttpsUrl), render_view_host1());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // A provisional same-site navigation is interrupted by a cross-process 317 // A provisional same-site navigation is interrupted by a cross-process
318 // navigation without sending an abort first. 318 // navigation without sending an abort first.
319 TEST_F(CaptivePortalTabHelperTest, UnexpectedProvisionalLoad) { 319 TEST_F(CaptivePortalTabHelperTest, UnexpectedProvisionalLoad) {
320 GURL same_site_url = GURL(kHttpUrl); 320 GURL same_site_url = GURL(kHttpUrl);
321 GURL cross_process_url = GURL(kHttpsUrl2); 321 GURL cross_process_url = GURL(kHttpsUrl2);
322 322
323 // A same-site load for the original RenderViewHost starts. 323 // A same-site load for the original RenderViewHost starts.
324 EXPECT_CALL(mock_reloader(), 324 EXPECT_CALL(mock_reloader(),
325 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); 325 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1);
326 tab_helper().DidStartProvisionalLoadForFrame( 326 tab_helper().DidStartProvisionalLoadForFrame(
327 1, true, same_site_url, false, render_view_host1()); 327 1, -1, true, same_site_url, false, render_view_host1());
328 328
329 // It's unexpectedly interrupted by a cross-process navigation, which starts 329 // It's unexpectedly interrupted by a cross-process navigation, which starts
330 // navigating before the old navigation cancels. We generate an abort message 330 // navigating before the old navigation cancels. We generate an abort message
331 // for the old navigation. 331 // for the old navigation.
332 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 332 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
333 EXPECT_CALL(mock_reloader(), 333 EXPECT_CALL(mock_reloader(),
334 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1); 334 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1);
335 tab_helper().DidStartProvisionalLoadForFrame( 335 tab_helper().DidStartProvisionalLoadForFrame(
336 1, true, cross_process_url, false, render_view_host2()); 336 1, -1, true, cross_process_url, false, render_view_host2());
337 337
338 // The cross-process navigation fails. 338 // The cross-process navigation fails.
339 tab_helper().DidFailProvisionalLoad( 339 tab_helper().DidFailProvisionalLoad(
340 1, true, cross_process_url, net::ERR_FAILED, string16(), 340 1, true, cross_process_url, net::ERR_FAILED, string16(),
341 render_view_host2()); 341 render_view_host2());
342 342
343 // The same-site navigation finally is aborted. 343 // The same-site navigation finally is aborted.
344 tab_helper().DidFailProvisionalLoad( 344 tab_helper().DidFailProvisionalLoad(
345 1, true, same_site_url, net::ERR_ABORTED, string16(), 345 1, true, same_site_url, net::ERR_ABORTED, string16(),
346 render_view_host1()); 346 render_view_host1());
347 347
348 // The provisional load starts for the error page for the cross-process 348 // The provisional load starts for the error page for the cross-process
349 // navigation. 349 // navigation.
350 tab_helper().DidStartProvisionalLoadForFrame( 350 tab_helper().DidStartProvisionalLoadForFrame(
351 1, true, GURL(kErrorPageUrl), true, render_view_host2()); 351 1, -1, true, GURL(kErrorPageUrl), true, render_view_host2());
352 352
353 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1); 353 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1);
354 tab_helper().DidCommitProvisionalLoadForFrame( 354 tab_helper().DidCommitProvisionalLoadForFrame(
355 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_TYPED, 355 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_TYPED,
356 render_view_host2()); 356 render_view_host2());
357 } 357 }
358 358
359 // Similar to the above test, except the original RenderViewHost manages to 359 // Similar to the above test, except the original RenderViewHost manages to
360 // commit before its navigation is aborted. 360 // commit before its navigation is aborted.
361 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) { 361 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) {
362 GURL same_site_url = GURL(kHttpUrl); 362 GURL same_site_url = GURL(kHttpUrl);
363 GURL cross_process_url = GURL(kHttpsUrl2); 363 GURL cross_process_url = GURL(kHttpsUrl2);
364 364
365 // A same-site load for the original RenderViewHost starts. 365 // A same-site load for the original RenderViewHost starts.
366 EXPECT_CALL(mock_reloader(), 366 EXPECT_CALL(mock_reloader(),
367 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); 367 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1);
368 tab_helper().DidStartProvisionalLoadForFrame( 368 tab_helper().DidStartProvisionalLoadForFrame(
369 1, true, same_site_url, false, render_view_host1()); 369 1, -1, true, same_site_url, false, render_view_host1());
370 370
371 // It's unexpectedly interrupted by a cross-process navigation, which starts 371 // It's unexpectedly interrupted by a cross-process navigation, which starts
372 // navigating before the old navigation cancels. We generate an abort message 372 // navigating before the old navigation cancels. We generate an abort message
373 // for the old navigation. 373 // for the old navigation.
374 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 374 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
375 EXPECT_CALL(mock_reloader(), 375 EXPECT_CALL(mock_reloader(),
376 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1); 376 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1);
377 tab_helper().DidStartProvisionalLoadForFrame( 377 tab_helper().DidStartProvisionalLoadForFrame(
378 1, true, cross_process_url, false, render_view_host2()); 378 1, -1, true, cross_process_url, false, render_view_host2());
379 379
380 // The cross-process navigation fails. 380 // The cross-process navigation fails.
381 tab_helper().DidFailProvisionalLoad( 381 tab_helper().DidFailProvisionalLoad(
382 1, true, cross_process_url, net::ERR_FAILED, string16(), 382 1, true, cross_process_url, net::ERR_FAILED, string16(),
383 render_view_host2()); 383 render_view_host2());
384 384
385 // The same-site navigation succeeds. 385 // The same-site navigation succeeds.
386 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 386 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
387 EXPECT_CALL(mock_reloader(), 387 EXPECT_CALL(mock_reloader(),
388 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); 388 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1);
389 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 389 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
390 tab_helper().DidCommitProvisionalLoadForFrame( 390 tab_helper().DidCommitProvisionalLoadForFrame(
391 1, true, same_site_url, content::PAGE_TRANSITION_LINK, 391 1, true, same_site_url, content::PAGE_TRANSITION_LINK,
392 render_view_host1()); 392 render_view_host1());
393 } 393 }
394 394
395 // Simulates navigations for a number of subframes, and makes sure no 395 // Simulates navigations for a number of subframes, and makes sure no
396 // CaptivePortalTabHelper function is called. 396 // CaptivePortalTabHelper function is called.
397 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) { 397 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) {
398 GURL url = GURL(kHttpsUrl); 398 GURL url = GURL(kHttpsUrl);
399 // Normal load. 399 // Normal load.
400 tab_helper().DidStartProvisionalLoadForFrame( 400 tab_helper().DidStartProvisionalLoadForFrame(
401 1, false, url, false, render_view_host1()); 401 1, -1, false, url, false, render_view_host1());
402 tab_helper().DidCommitProvisionalLoadForFrame( 402 tab_helper().DidCommitProvisionalLoadForFrame(
403 1, false, url, content::PAGE_TRANSITION_LINK, render_view_host1()); 403 1, false, url, content::PAGE_TRANSITION_LINK, render_view_host1());
404 404
405 // Timeout. 405 // Timeout.
406 tab_helper().DidStartProvisionalLoadForFrame( 406 tab_helper().DidStartProvisionalLoadForFrame(
407 2, false, url, false, render_view_host1()); 407 2, -1, false, url, false, render_view_host1());
408 tab_helper().DidFailProvisionalLoad( 408 tab_helper().DidFailProvisionalLoad(
409 2, false, url, net::ERR_TIMED_OUT, string16(), render_view_host1()); 409 2, false, url, net::ERR_TIMED_OUT, string16(), render_view_host1());
410 tab_helper().DidStartProvisionalLoadForFrame( 410 tab_helper().DidStartProvisionalLoadForFrame(
411 2, false, url, true, render_view_host1()); 411 2, -1, false, url, true, render_view_host1());
412 tab_helper().DidFailProvisionalLoad( 412 tab_helper().DidFailProvisionalLoad(
413 2, false, url, net::ERR_ABORTED, string16(), render_view_host1()); 413 2, false, url, net::ERR_ABORTED, string16(), render_view_host1());
414 414
415 // Abort. 415 // Abort.
416 tab_helper().DidStartProvisionalLoadForFrame( 416 tab_helper().DidStartProvisionalLoadForFrame(
417 3, false, url, false, render_view_host1()); 417 3, -1, false, url, false, render_view_host1());
418 tab_helper().DidFailProvisionalLoad( 418 tab_helper().DidFailProvisionalLoad(
419 3, false, url, net::ERR_ABORTED, string16(), render_view_host1()); 419 3, false, url, net::ERR_ABORTED, string16(), render_view_host1());
420 } 420 }
421 421
422 // Simulates a subframe erroring out at the same time as a provisional load, 422 // Simulates a subframe erroring out at the same time as a provisional load,
423 // but with a different error code. Make sure the TabHelper sees the correct 423 // but with a different error code. Make sure the TabHelper sees the correct
424 // error. 424 // error.
425 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) { 425 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) {
426 // URL used by both frames. 426 // URL used by both frames.
427 GURL url = GURL(kHttpsUrl); 427 GURL url = GURL(kHttpsUrl);
428 428
429 int frame_id = 2; 429 int frame_id = 2;
430 int subframe_id = 1; 430 int subframe_id = 1;
431 431
432 // Loads start. 432 // Loads start.
433 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 433 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
434 tab_helper().DidStartProvisionalLoadForFrame( 434 tab_helper().DidStartProvisionalLoadForFrame(
435 frame_id, true, url, false, render_view_host1()); 435 frame_id, -1, true, url, false, render_view_host1());
436 tab_helper().DidStartProvisionalLoadForFrame( 436 tab_helper().DidStartProvisionalLoadForFrame(
437 subframe_id, false, url, false, render_view_host1()); 437 subframe_id, frame_id, false, url, false, render_view_host1());
438 438
439 // Loads return errors. 439 // Loads return errors.
440 tab_helper().DidFailProvisionalLoad( 440 tab_helper().DidFailProvisionalLoad(
441 frame_id, true, url, net::ERR_UNEXPECTED, string16(), 441 frame_id, true, url, net::ERR_UNEXPECTED, string16(),
442 render_view_host1()); 442 render_view_host1());
443 tab_helper().DidFailProvisionalLoad( 443 tab_helper().DidFailProvisionalLoad(
444 subframe_id, false, url, net::ERR_TIMED_OUT, string16(), 444 subframe_id, false, url, net::ERR_TIMED_OUT, string16(),
445 render_view_host1()); 445 render_view_host1());
446 446
447 // Provisional load starts for the error pages. 447 // Provisional load starts for the error pages.
448 tab_helper().DidStartProvisionalLoadForFrame( 448 tab_helper().DidStartProvisionalLoadForFrame(
449 frame_id, true, url, true, render_view_host1()); 449 frame_id, -1, true, url, true, render_view_host1());
450 tab_helper().DidStartProvisionalLoadForFrame( 450 tab_helper().DidStartProvisionalLoadForFrame(
451 subframe_id, false, url, true, render_view_host1()); 451 subframe_id, frame_id, false, url, true, render_view_host1());
452 452
453 // Error page load finishes. 453 // Error page load finishes.
454 tab_helper().DidCommitProvisionalLoadForFrame( 454 tab_helper().DidCommitProvisionalLoadForFrame(
455 subframe_id, false, url, content::PAGE_TRANSITION_AUTO_SUBFRAME, 455 subframe_id, false, url, content::PAGE_TRANSITION_AUTO_SUBFRAME,
456 render_view_host1()); 456 render_view_host1());
457 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); 457 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1);
458 tab_helper().DidCommitProvisionalLoadForFrame( 458 tab_helper().DidCommitProvisionalLoadForFrame(
459 frame_id, true, url, content::PAGE_TRANSITION_LINK, 459 frame_id, true, url, content::PAGE_TRANSITION_LINK,
460 render_view_host1()); 460 render_view_host1());
461 } 461 }
462 462
463 // Simulates an HTTP to HTTPS redirect, which then times out. 463 // Simulates an HTTP to HTTPS redirect, which then times out.
464 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { 464 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) {
465 GURL http_url(kHttpUrl); 465 GURL http_url(kHttpUrl);
466 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 466 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
467 tab_helper().DidStartProvisionalLoadForFrame( 467 tab_helper().DidStartProvisionalLoadForFrame(
468 1, true, http_url, false, render_view_host1()); 468 1, -1, true, http_url, false, render_view_host1());
469 469
470 GURL https_url(kHttpsUrl); 470 GURL https_url(kHttpsUrl);
471 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); 471 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1);
472 OnRedirect(ResourceType::MAIN_FRAME, https_url, 472 OnRedirect(ResourceType::MAIN_FRAME, https_url,
473 render_view_host1()->GetProcess()->GetID()); 473 render_view_host1()->GetProcess()->GetID());
474 474
475 tab_helper().DidFailProvisionalLoad( 475 tab_helper().DidFailProvisionalLoad(
476 1, true, https_url, net::ERR_TIMED_OUT, string16(), 476 1, true, https_url, net::ERR_TIMED_OUT, string16(),
477 render_view_host1()); 477 render_view_host1());
478 478
479 // Provisional load starts for the error page. 479 // Provisional load starts for the error page.
480 tab_helper().DidStartProvisionalLoadForFrame( 480 tab_helper().DidStartProvisionalLoadForFrame(
481 1, true, GURL(kErrorPageUrl), true, render_view_host1()); 481 1, -1, true, GURL(kErrorPageUrl), true, render_view_host1());
482 482
483 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 483 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
484 tab_helper().DidCommitProvisionalLoadForFrame( 484 tab_helper().DidCommitProvisionalLoadForFrame(
485 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 485 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK,
486 render_view_host1()); 486 render_view_host1());
487 } 487 }
488 488
489 // Simulates an HTTPS to HTTP redirect. 489 // Simulates an HTTPS to HTTP redirect.
490 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) { 490 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) {
491 GURL https_url(kHttpsUrl); 491 GURL https_url(kHttpsUrl);
492 EXPECT_CALL(mock_reloader(), 492 EXPECT_CALL(mock_reloader(),
493 OnLoadStart(https_url.SchemeIsSecure())).Times(1); 493 OnLoadStart(https_url.SchemeIsSecure())).Times(1);
494 tab_helper().DidStartProvisionalLoadForFrame(1, true, https_url, false, 494 tab_helper().DidStartProvisionalLoadForFrame(1, -1, true, https_url, false,
495 render_view_host1()); 495 render_view_host1());
496 496
497 GURL http_url(kHttpUrl); 497 GURL http_url(kHttpUrl);
498 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); 498 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1);
499 OnRedirect(ResourceType::MAIN_FRAME, http_url, 499 OnRedirect(ResourceType::MAIN_FRAME, http_url,
500 render_view_host1()->GetProcess()->GetID()); 500 render_view_host1()->GetProcess()->GetID());
501 501
502 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 502 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
503 tab_helper().DidCommitProvisionalLoadForFrame( 503 tab_helper().DidCommitProvisionalLoadForFrame(
504 1, true, http_url, content::PAGE_TRANSITION_LINK, 504 1, true, http_url, content::PAGE_TRANSITION_LINK,
505 render_view_host1()); 505 render_view_host1());
506 } 506 }
507 507
508 // Simulates an HTTPS to HTTPS redirect. 508 // Simulates an HTTPS to HTTPS redirect.
509 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) { 509 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) {
510 GURL http_url(kHttpUrl); 510 GURL http_url(kHttpUrl);
511 EXPECT_CALL(mock_reloader(), 511 EXPECT_CALL(mock_reloader(),
512 OnLoadStart(http_url.SchemeIsSecure())).Times(1); 512 OnLoadStart(http_url.SchemeIsSecure())).Times(1);
513 tab_helper().DidStartProvisionalLoadForFrame( 513 tab_helper().DidStartProvisionalLoadForFrame(
514 1, true, http_url, false, render_view_host1()); 514 1, -1, true, http_url, false, render_view_host1());
515 515
516 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); 516 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1);
517 OnRedirect(ResourceType::MAIN_FRAME, http_url, 517 OnRedirect(ResourceType::MAIN_FRAME, http_url,
518 render_view_host1()->GetProcess()->GetID()); 518 render_view_host1()->GetProcess()->GetID());
519 519
520 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 520 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
521 tab_helper().DidCommitProvisionalLoadForFrame( 521 tab_helper().DidCommitProvisionalLoadForFrame(
522 1, true, http_url, content::PAGE_TRANSITION_LINK, 522 1, true, http_url, content::PAGE_TRANSITION_LINK,
523 render_view_host1()); 523 render_view_host1());
524 } 524 }
525 525
526 // Simulates redirect of a subframe. 526 // Simulates redirect of a subframe.
527 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) { 527 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) {
528 GURL http_url(kHttpUrl); 528 GURL http_url(kHttpUrl);
529 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 529 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
530 tab_helper().DidStartProvisionalLoadForFrame( 530 tab_helper().DidStartProvisionalLoadForFrame(
531 1, true, http_url, false, render_view_host1()); 531 1, -1, true, http_url, false, render_view_host1());
532 532
533 GURL https_url(kHttpsUrl); 533 GURL https_url(kHttpsUrl);
534 OnRedirect(ResourceType::SUB_FRAME, https_url, 534 OnRedirect(ResourceType::SUB_FRAME, https_url,
535 render_view_host1()->GetProcess()->GetID()); 535 render_view_host1()->GetProcess()->GetID());
536 536
537 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 537 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
538 tab_helper().DidCommitProvisionalLoadForFrame( 538 tab_helper().DidCommitProvisionalLoadForFrame(
539 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 539 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK,
540 render_view_host1()); 540 render_view_host1());
541 } 541 }
542 542
543 // Simulates a redirect, for another RenderViewHost. 543 // Simulates a redirect, for another RenderViewHost.
544 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) { 544 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) {
545 GURL http_url(kHttpUrl); 545 GURL http_url(kHttpUrl);
546 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 546 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
547 tab_helper().DidStartProvisionalLoadForFrame( 547 tab_helper().DidStartProvisionalLoadForFrame(
548 1, true, http_url, false, render_view_host1()); 548 1, -1, true, http_url, false, render_view_host1());
549 549
550 // Another RenderViewHost sees a redirect. None of the reloader's functions 550 // Another RenderViewHost sees a redirect. None of the reloader's functions
551 // should be called. 551 // should be called.
552 GURL https_url(kHttpsUrl); 552 GURL https_url(kHttpsUrl);
553 OnRedirect(ResourceType::MAIN_FRAME, https_url, 553 OnRedirect(ResourceType::MAIN_FRAME, https_url,
554 render_view_host2()->GetProcess()->GetID()); 554 render_view_host2()->GetProcess()->GetID());
555 555
556 tab_helper().DidFailProvisionalLoad( 556 tab_helper().DidFailProvisionalLoad(
557 1, true, https_url, net::ERR_TIMED_OUT, string16(), 557 1, true, https_url, net::ERR_TIMED_OUT, string16(),
558 render_view_host1()); 558 render_view_host1());
559 559
560 // Provisional load starts for the error page. 560 // Provisional load starts for the error page.
561 tab_helper().DidStartProvisionalLoadForFrame( 561 tab_helper().DidStartProvisionalLoadForFrame(
562 1, true, GURL(kErrorPageUrl), true, render_view_host1()); 562 1, -1, true, GURL(kErrorPageUrl), true, render_view_host1());
563 563
564 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 564 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
565 tab_helper().DidCommitProvisionalLoadForFrame( 565 tab_helper().DidCommitProvisionalLoadForFrame(
566 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 566 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK,
567 render_view_host1()); 567 render_view_host1());
568 } 568 }
569 569
570 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) { 570 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) {
571 EXPECT_FALSE(tab_helper().IsLoginTab()); 571 EXPECT_FALSE(tab_helper().IsLoginTab());
572 SetIsLoginTab(); 572 SetIsLoginTab();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 EXPECT_FALSE(tab_helper().IsLoginTab()); 610 EXPECT_FALSE(tab_helper().IsLoginTab());
611 611
612 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); 612 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE);
613 EXPECT_FALSE(tab_helper().IsLoginTab()); 613 EXPECT_FALSE(tab_helper().IsLoginTab());
614 614
615 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); 615 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED);
616 EXPECT_FALSE(tab_helper().IsLoginTab()); 616 EXPECT_FALSE(tab_helper().IsLoginTab());
617 } 617 }
618 618
619 } // namespace captive_portal 619 } // namespace captive_portal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698