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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 25654005: Remove GetActiveEntry usage from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comment, added TODO, rebased on ToT. Created 7 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/renderer_host/test_render_view_host.h" 8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/web_contents/interstitial_page_impl.h" 10 #include "content/browser/web_contents/interstitial_page_impl.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 // Navigate to URL 369 // Navigate to URL
370 const GURL url("http://www.google.com"); 370 const GURL url("http://www.google.com");
371 controller().LoadURL( 371 controller().LoadURL(
372 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 372 url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
373 EXPECT_FALSE(contents()->cross_navigation_pending()); 373 EXPECT_FALSE(contents()->cross_navigation_pending());
374 EXPECT_EQ(instance1, orig_rvh->GetSiteInstance()); 374 EXPECT_EQ(instance1, orig_rvh->GetSiteInstance());
375 // Controller's pending entry will have a NULL site instance until we assign 375 // Controller's pending entry will have a NULL site instance until we assign
376 // it in DidNavigate. 376 // it in DidNavigate.
377 EXPECT_TRUE( 377 EXPECT_TRUE(
378 NavigationEntryImpl::FromNavigationEntry(controller().GetActiveEntry())-> 378 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())->
379 site_instance() == NULL); 379 site_instance() == NULL);
380 380
381 // DidNavigate from the page 381 // DidNavigate from the page
382 contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED); 382 contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED);
383 EXPECT_FALSE(contents()->cross_navigation_pending()); 383 EXPECT_FALSE(contents()->cross_navigation_pending());
384 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost()); 384 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
385 EXPECT_EQ(instance1, orig_rvh->GetSiteInstance()); 385 EXPECT_EQ(instance1, orig_rvh->GetSiteInstance());
386 // Controller's entry should now have the SiteInstance, or else we won't be 386 // Controller's entry should now have the SiteInstance, or else we won't be
387 // able to find it later. 387 // able to find it later.
388 EXPECT_EQ( 388 EXPECT_EQ(
389 instance1, 389 instance1,
390 NavigationEntryImpl::FromNavigationEntry(controller().GetActiveEntry())-> 390 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())->
391 site_instance()); 391 site_instance());
392 } 392 }
393 393
394 // Test that we reject NavigateToEntry if the url is over kMaxURLChars. 394 // Test that we reject NavigateToEntry if the url is over kMaxURLChars.
395 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { 395 TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) {
396 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. 396 // Construct a URL that's kMaxURLChars + 1 long of all 'a's.
397 const GURL url(std::string("http://example.org/").append( 397 const GURL url(std::string("http://example.org/").append(
398 kMaxURLChars + 1, 'a')); 398 kMaxURLChars + 1, 'a'));
399 399
400 controller().LoadURL( 400 controller().LoadURL(
401 url, Referrer(), PAGE_TRANSITION_GENERATED, std::string()); 401 url, Referrer(), PAGE_TRANSITION_GENERATED, std::string());
402 EXPECT_TRUE(controller().GetActiveEntry() == NULL); 402 EXPECT_TRUE(controller().GetVisibleEntry() == NULL);
403 } 403 }
404 404
405 // Test that navigating across a site boundary creates a new RenderViewHost 405 // Test that navigating across a site boundary creates a new RenderViewHost
406 // with a new SiteInstance. Going back should do the same. 406 // with a new SiteInstance. Going back should do the same.
407 TEST_F(WebContentsImplTest, CrossSiteBoundaries) { 407 TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
408 contents()->transition_cross_site = true; 408 contents()->transition_cross_site = true;
409 TestRenderViewHost* orig_rvh = test_rvh(); 409 TestRenderViewHost* orig_rvh = test_rvh();
410 int orig_rvh_delete_count = 0; 410 int orig_rvh_delete_count = 0;
411 orig_rvh->set_delete_counter(&orig_rvh_delete_count); 411 orig_rvh->set_delete_counter(&orig_rvh_delete_count);
412 SiteInstance* instance1 = contents()->GetSiteInstance(); 412 SiteInstance* instance1 = contents()->GetSiteInstance();
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 interstitial->Show(); 1225 interstitial->Show();
1226 // The interstitial should not show until its navigation has committed. 1226 // The interstitial should not show until its navigation has committed.
1227 EXPECT_FALSE(interstitial->is_showing()); 1227 EXPECT_FALSE(interstitial->is_showing());
1228 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1228 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1229 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1229 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1230 // Let's commit the interstitial navigation. 1230 // Let's commit the interstitial navigation.
1231 interstitial->TestDidNavigate(1, url2); 1231 interstitial->TestDidNavigate(1, url2);
1232 EXPECT_TRUE(interstitial->is_showing()); 1232 EXPECT_TRUE(interstitial->is_showing());
1233 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1233 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1234 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1234 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1235 NavigationEntry* entry = controller().GetActiveEntry(); 1235 NavigationEntry* entry = controller().GetVisibleEntry();
1236 ASSERT_TRUE(entry != NULL); 1236 ASSERT_TRUE(entry != NULL);
1237 EXPECT_TRUE(entry->GetURL() == url2); 1237 EXPECT_TRUE(entry->GetURL() == url2);
1238 1238
1239 // Now don't proceed. 1239 // Now don't proceed.
1240 interstitial->DontProceed(); 1240 interstitial->DontProceed();
1241 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1241 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1242 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1242 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1243 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1243 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1244 entry = controller().GetActiveEntry(); 1244 entry = controller().GetVisibleEntry();
1245 ASSERT_TRUE(entry != NULL); 1245 ASSERT_TRUE(entry != NULL);
1246 EXPECT_TRUE(entry->GetURL() == url1); 1246 EXPECT_TRUE(entry->GetURL() == url1);
1247 EXPECT_EQ(1, controller().GetEntryCount()); 1247 EXPECT_EQ(1, controller().GetEntryCount());
1248 1248
1249 RunAllPendingInMessageLoop(); 1249 RunAllPendingInMessageLoop();
1250 EXPECT_TRUE(deleted); 1250 EXPECT_TRUE(deleted);
1251 } 1251 }
1252 1252
1253 // Test navigating to a page (with the navigation initiated from the renderer, 1253 // Test navigating to a page (with the navigation initiated from the renderer,
1254 // as when clicking on a link in the page) that shows an interstitial and 1254 // as when clicking on a link in the page) that shows an interstitial and
(...skipping 17 matching lines...) Expand all
1272 interstitial->Show(); 1272 interstitial->Show();
1273 // The interstitial should not show until its navigation has committed. 1273 // The interstitial should not show until its navigation has committed.
1274 EXPECT_FALSE(interstitial->is_showing()); 1274 EXPECT_FALSE(interstitial->is_showing());
1275 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1275 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1276 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1276 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1277 // Let's commit the interstitial navigation. 1277 // Let's commit the interstitial navigation.
1278 interstitial->TestDidNavigate(1, url2); 1278 interstitial->TestDidNavigate(1, url2);
1279 EXPECT_TRUE(interstitial->is_showing()); 1279 EXPECT_TRUE(interstitial->is_showing());
1280 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1280 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1281 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1281 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1282 NavigationEntry* entry = controller().GetActiveEntry(); 1282 NavigationEntry* entry = controller().GetVisibleEntry();
1283 ASSERT_TRUE(entry != NULL); 1283 ASSERT_TRUE(entry != NULL);
1284 EXPECT_TRUE(entry->GetURL() == url2); 1284 EXPECT_TRUE(entry->GetURL() == url2);
1285 1285
1286 // Now don't proceed. 1286 // Now don't proceed.
1287 interstitial->DontProceed(); 1287 interstitial->DontProceed();
1288 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1288 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1289 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1289 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1290 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1290 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1291 entry = controller().GetActiveEntry(); 1291 entry = controller().GetVisibleEntry();
1292 ASSERT_TRUE(entry != NULL); 1292 ASSERT_TRUE(entry != NULL);
1293 EXPECT_TRUE(entry->GetURL() == url1); 1293 EXPECT_TRUE(entry->GetURL() == url1);
1294 EXPECT_EQ(1, controller().GetEntryCount()); 1294 EXPECT_EQ(1, controller().GetEntryCount());
1295 1295
1296 RunAllPendingInMessageLoop(); 1296 RunAllPendingInMessageLoop();
1297 EXPECT_TRUE(deleted); 1297 EXPECT_TRUE(deleted);
1298 } 1298 }
1299 1299
1300 // Test navigating to a page that shows an interstitial without creating a new 1300 // Test navigating to a page that shows an interstitial without creating a new
1301 // navigation entry (this happens when the interstitial is triggered by a 1301 // navigation entry (this happens when the interstitial is triggered by a
(...skipping 15 matching lines...) Expand all
1317 interstitial->Show(); 1317 interstitial->Show();
1318 // The interstitial should not show until its navigation has committed. 1318 // The interstitial should not show until its navigation has committed.
1319 EXPECT_FALSE(interstitial->is_showing()); 1319 EXPECT_FALSE(interstitial->is_showing());
1320 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1320 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1321 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1321 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1322 // Let's commit the interstitial navigation. 1322 // Let's commit the interstitial navigation.
1323 interstitial->TestDidNavigate(1, url2); 1323 interstitial->TestDidNavigate(1, url2);
1324 EXPECT_TRUE(interstitial->is_showing()); 1324 EXPECT_TRUE(interstitial->is_showing());
1325 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1325 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1326 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1326 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1327 NavigationEntry* entry = controller().GetActiveEntry(); 1327 NavigationEntry* entry = controller().GetVisibleEntry();
1328 ASSERT_TRUE(entry != NULL); 1328 ASSERT_TRUE(entry != NULL);
1329 // The URL specified to the interstitial should have been ignored. 1329 // The URL specified to the interstitial should have been ignored.
1330 EXPECT_TRUE(entry->GetURL() == url1); 1330 EXPECT_TRUE(entry->GetURL() == url1);
1331 1331
1332 // Now don't proceed. 1332 // Now don't proceed.
1333 interstitial->DontProceed(); 1333 interstitial->DontProceed();
1334 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1334 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1335 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1335 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1336 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1336 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1337 entry = controller().GetActiveEntry(); 1337 entry = controller().GetVisibleEntry();
1338 ASSERT_TRUE(entry != NULL); 1338 ASSERT_TRUE(entry != NULL);
1339 EXPECT_TRUE(entry->GetURL() == url1); 1339 EXPECT_TRUE(entry->GetURL() == url1);
1340 EXPECT_EQ(1, controller().GetEntryCount()); 1340 EXPECT_EQ(1, controller().GetEntryCount());
1341 1341
1342 RunAllPendingInMessageLoop(); 1342 RunAllPendingInMessageLoop();
1343 EXPECT_TRUE(deleted); 1343 EXPECT_TRUE(deleted);
1344 } 1344 }
1345 1345
1346 // Test navigating to a page (with the navigation initiated from the browser, 1346 // Test navigating to a page (with the navigation initiated from the browser,
1347 // as when a URL is typed in the location bar) that shows an interstitial and 1347 // as when a URL is typed in the location bar) that shows an interstitial and
(...skipping 20 matching lines...) Expand all
1368 interstitial->Show(); 1368 interstitial->Show();
1369 // The interstitial should not show until its navigation has committed. 1369 // The interstitial should not show until its navigation has committed.
1370 EXPECT_FALSE(interstitial->is_showing()); 1370 EXPECT_FALSE(interstitial->is_showing());
1371 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1371 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1372 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1372 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1373 // Let's commit the interstitial navigation. 1373 // Let's commit the interstitial navigation.
1374 interstitial->TestDidNavigate(1, url2); 1374 interstitial->TestDidNavigate(1, url2);
1375 EXPECT_TRUE(interstitial->is_showing()); 1375 EXPECT_TRUE(interstitial->is_showing());
1376 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1376 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1377 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1377 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1378 NavigationEntry* entry = controller().GetActiveEntry(); 1378 NavigationEntry* entry = controller().GetVisibleEntry();
1379 ASSERT_TRUE(entry != NULL); 1379 ASSERT_TRUE(entry != NULL);
1380 EXPECT_TRUE(entry->GetURL() == url2); 1380 EXPECT_TRUE(entry->GetURL() == url2);
1381 1381
1382 // Then proceed. 1382 // Then proceed.
1383 interstitial->Proceed(); 1383 interstitial->Proceed();
1384 // The interstitial should show until the new navigation commits. 1384 // The interstitial should show until the new navigation commits.
1385 RunAllPendingInMessageLoop(); 1385 RunAllPendingInMessageLoop();
1386 ASSERT_FALSE(deleted); 1386 ASSERT_FALSE(deleted);
1387 EXPECT_EQ(TestInterstitialPage::OKED, state); 1387 EXPECT_EQ(TestInterstitialPage::OKED, state);
1388 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1388 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1389 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1389 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1390 1390
1391 // Simulate the navigation to the page, that's when the interstitial gets 1391 // Simulate the navigation to the page, that's when the interstitial gets
1392 // hidden. 1392 // hidden.
1393 GURL url3("http://www.thepage.com"); 1393 GURL url3("http://www.thepage.com");
1394 test_rvh()->SendNavigate(2, url3); 1394 test_rvh()->SendNavigate(2, url3);
1395 1395
1396 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1396 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1397 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1397 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1398 entry = controller().GetActiveEntry(); 1398 entry = controller().GetVisibleEntry();
1399 ASSERT_TRUE(entry != NULL); 1399 ASSERT_TRUE(entry != NULL);
1400 EXPECT_TRUE(entry->GetURL() == url3); 1400 EXPECT_TRUE(entry->GetURL() == url3);
1401 1401
1402 EXPECT_EQ(2, controller().GetEntryCount()); 1402 EXPECT_EQ(2, controller().GetEntryCount());
1403 1403
1404 RunAllPendingInMessageLoop(); 1404 RunAllPendingInMessageLoop();
1405 EXPECT_TRUE(deleted); 1405 EXPECT_TRUE(deleted);
1406 } 1406 }
1407 1407
1408 // Test navigating to a page (with the navigation initiated from the renderer, 1408 // Test navigating to a page (with the navigation initiated from the renderer,
(...skipping 17 matching lines...) Expand all
1426 interstitial->Show(); 1426 interstitial->Show();
1427 // The interstitial should not show until its navigation has committed. 1427 // The interstitial should not show until its navigation has committed.
1428 EXPECT_FALSE(interstitial->is_showing()); 1428 EXPECT_FALSE(interstitial->is_showing());
1429 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1429 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1430 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1430 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1431 // Let's commit the interstitial navigation. 1431 // Let's commit the interstitial navigation.
1432 interstitial->TestDidNavigate(1, url2); 1432 interstitial->TestDidNavigate(1, url2);
1433 EXPECT_TRUE(interstitial->is_showing()); 1433 EXPECT_TRUE(interstitial->is_showing());
1434 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1434 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1435 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1435 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1436 NavigationEntry* entry = controller().GetActiveEntry(); 1436 NavigationEntry* entry = controller().GetVisibleEntry();
1437 ASSERT_TRUE(entry != NULL); 1437 ASSERT_TRUE(entry != NULL);
1438 EXPECT_TRUE(entry->GetURL() == url2); 1438 EXPECT_TRUE(entry->GetURL() == url2);
1439 1439
1440 // Then proceed. 1440 // Then proceed.
1441 interstitial->Proceed(); 1441 interstitial->Proceed();
1442 // The interstitial should show until the new navigation commits. 1442 // The interstitial should show until the new navigation commits.
1443 RunAllPendingInMessageLoop(); 1443 RunAllPendingInMessageLoop();
1444 ASSERT_FALSE(deleted); 1444 ASSERT_FALSE(deleted);
1445 EXPECT_EQ(TestInterstitialPage::OKED, state); 1445 EXPECT_EQ(TestInterstitialPage::OKED, state);
1446 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1446 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1447 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1447 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1448 1448
1449 // Simulate the navigation to the page, that's when the interstitial gets 1449 // Simulate the navigation to the page, that's when the interstitial gets
1450 // hidden. 1450 // hidden.
1451 GURL url3("http://www.thepage.com"); 1451 GURL url3("http://www.thepage.com");
1452 test_rvh()->SendNavigate(2, url3); 1452 test_rvh()->SendNavigate(2, url3);
1453 1453
1454 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1454 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1455 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1455 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1456 entry = controller().GetActiveEntry(); 1456 entry = controller().GetVisibleEntry();
1457 ASSERT_TRUE(entry != NULL); 1457 ASSERT_TRUE(entry != NULL);
1458 EXPECT_TRUE(entry->GetURL() == url3); 1458 EXPECT_TRUE(entry->GetURL() == url3);
1459 1459
1460 EXPECT_EQ(2, controller().GetEntryCount()); 1460 EXPECT_EQ(2, controller().GetEntryCount());
1461 1461
1462 RunAllPendingInMessageLoop(); 1462 RunAllPendingInMessageLoop();
1463 EXPECT_TRUE(deleted); 1463 EXPECT_TRUE(deleted);
1464 } 1464 }
1465 1465
1466 // Test navigating to a page that shows an interstitial without creating a new 1466 // Test navigating to a page that shows an interstitial without creating a new
(...skipping 16 matching lines...) Expand all
1483 interstitial->Show(); 1483 interstitial->Show();
1484 // The interstitial should not show until its navigation has committed. 1484 // The interstitial should not show until its navigation has committed.
1485 EXPECT_FALSE(interstitial->is_showing()); 1485 EXPECT_FALSE(interstitial->is_showing());
1486 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1486 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1487 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1487 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1488 // Let's commit the interstitial navigation. 1488 // Let's commit the interstitial navigation.
1489 interstitial->TestDidNavigate(1, url2); 1489 interstitial->TestDidNavigate(1, url2);
1490 EXPECT_TRUE(interstitial->is_showing()); 1490 EXPECT_TRUE(interstitial->is_showing());
1491 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1491 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1492 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1492 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1493 NavigationEntry* entry = controller().GetActiveEntry(); 1493 NavigationEntry* entry = controller().GetVisibleEntry();
1494 ASSERT_TRUE(entry != NULL); 1494 ASSERT_TRUE(entry != NULL);
1495 // The URL specified to the interstitial should have been ignored. 1495 // The URL specified to the interstitial should have been ignored.
1496 EXPECT_TRUE(entry->GetURL() == url1); 1496 EXPECT_TRUE(entry->GetURL() == url1);
1497 1497
1498 // Then proceed. 1498 // Then proceed.
1499 interstitial->Proceed(); 1499 interstitial->Proceed();
1500 // Since this is not a new navigation, the previous page is dismissed right 1500 // Since this is not a new navigation, the previous page is dismissed right
1501 // away and shows the original page. 1501 // away and shows the original page.
1502 EXPECT_EQ(TestInterstitialPage::OKED, state); 1502 EXPECT_EQ(TestInterstitialPage::OKED, state);
1503 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1503 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1504 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1504 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1505 entry = controller().GetActiveEntry(); 1505 entry = controller().GetVisibleEntry();
1506 ASSERT_TRUE(entry != NULL); 1506 ASSERT_TRUE(entry != NULL);
1507 EXPECT_TRUE(entry->GetURL() == url1); 1507 EXPECT_TRUE(entry->GetURL() == url1);
1508 1508
1509 EXPECT_EQ(1, controller().GetEntryCount()); 1509 EXPECT_EQ(1, controller().GetEntryCount());
1510 1510
1511 RunAllPendingInMessageLoop(); 1511 RunAllPendingInMessageLoop();
1512 EXPECT_TRUE(deleted); 1512 EXPECT_TRUE(deleted);
1513 } 1513 }
1514 1514
1515 // Test navigating to a page that shows an interstitial, then navigating away. 1515 // Test navigating to a page that shows an interstitial, then navigating away.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 interstitial->Show(); 1554 interstitial->Show();
1555 interstitial->TestDidNavigate(2, interstitial_url); 1555 interstitial->TestDidNavigate(2, interstitial_url);
1556 1556
1557 // While the interstitial is showing, go back. 1557 // While the interstitial is showing, go back.
1558 controller().GoBack(); 1558 controller().GoBack();
1559 test_rvh()->SendNavigate(1, url1); 1559 test_rvh()->SendNavigate(1, url1);
1560 1560
1561 // Make sure we are back to the original page and that the interstitial is 1561 // Make sure we are back to the original page and that the interstitial is
1562 // gone. 1562 // gone.
1563 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1563 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1564 NavigationEntry* entry = controller().GetActiveEntry(); 1564 NavigationEntry* entry = controller().GetVisibleEntry();
1565 ASSERT_TRUE(entry); 1565 ASSERT_TRUE(entry);
1566 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); 1566 EXPECT_EQ(url1.spec(), entry->GetURL().spec());
1567 1567
1568 RunAllPendingInMessageLoop(); 1568 RunAllPendingInMessageLoop();
1569 EXPECT_TRUE(deleted); 1569 EXPECT_TRUE(deleted);
1570 } 1570 }
1571 1571
1572 // Test navigating to a page that shows an interstitial, has a renderer crash, 1572 // Test navigating to a page that shows an interstitial, has a renderer crash,
1573 // and then goes back. 1573 // and then goes back.
1574 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { 1574 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) {
(...skipping 19 matching lines...) Expand all
1594 ViewHostMsg_RenderProcessGone( 1594 ViewHostMsg_RenderProcessGone(
1595 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1595 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1596 1596
1597 // While the interstitial is showing, go back. 1597 // While the interstitial is showing, go back.
1598 controller().GoBack(); 1598 controller().GoBack();
1599 test_rvh()->SendNavigate(1, url1); 1599 test_rvh()->SendNavigate(1, url1);
1600 1600
1601 // Make sure we are back to the original page and that the interstitial is 1601 // Make sure we are back to the original page and that the interstitial is
1602 // gone. 1602 // gone.
1603 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1603 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1604 NavigationEntry* entry = controller().GetActiveEntry(); 1604 NavigationEntry* entry = controller().GetVisibleEntry();
1605 ASSERT_TRUE(entry); 1605 ASSERT_TRUE(entry);
1606 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); 1606 EXPECT_EQ(url1.spec(), entry->GetURL().spec());
1607 1607
1608 RunAllPendingInMessageLoop(); 1608 RunAllPendingInMessageLoop();
1609 EXPECT_TRUE(deleted); 1609 EXPECT_TRUE(deleted);
1610 } 1610 }
1611 1611
1612 // Test navigating to a page that shows an interstitial, has the renderer crash, 1612 // Test navigating to a page that shows an interstitial, has the renderer crash,
1613 // and then navigates to the interstitial. 1613 // and then navigates to the interstitial.
1614 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) { 1614 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 EXPECT_TRUE(deleted1); 1761 EXPECT_TRUE(deleted1);
1762 ASSERT_FALSE(deleted2); 1762 ASSERT_FALSE(deleted2);
1763 1763
1764 // Let's make sure interstitial2 is working as intended. 1764 // Let's make sure interstitial2 is working as intended.
1765 interstitial2->Proceed(); 1765 interstitial2->Proceed();
1766 GURL landing_url("http://www.thepage.com"); 1766 GURL landing_url("http://www.thepage.com");
1767 test_rvh()->SendNavigate(2, landing_url); 1767 test_rvh()->SendNavigate(2, landing_url);
1768 1768
1769 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1769 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1770 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1770 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1771 NavigationEntry* entry = controller().GetActiveEntry(); 1771 NavigationEntry* entry = controller().GetVisibleEntry();
1772 ASSERT_TRUE(entry != NULL); 1772 ASSERT_TRUE(entry != NULL);
1773 EXPECT_TRUE(entry->GetURL() == landing_url); 1773 EXPECT_TRUE(entry->GetURL() == landing_url);
1774 EXPECT_EQ(2, controller().GetEntryCount()); 1774 EXPECT_EQ(2, controller().GetEntryCount());
1775 RunAllPendingInMessageLoop(); 1775 RunAllPendingInMessageLoop();
1776 EXPECT_TRUE(deleted2); 1776 EXPECT_TRUE(deleted2);
1777 } 1777 }
1778 1778
1779 // Test showing an interstitial, proceeding and then navigating to another 1779 // Test showing an interstitial, proceeding and then navigating to another
1780 // interstitial. 1780 // interstitial.
1781 TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { 1781 TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1820
1821 // Let's make sure interstitial2 is working as intended. 1821 // Let's make sure interstitial2 is working as intended.
1822 interstitial2->Proceed(); 1822 interstitial2->Proceed();
1823 GURL landing_url("http://www.thepage.com"); 1823 GURL landing_url("http://www.thepage.com");
1824 test_rvh()->SendNavigate(2, landing_url); 1824 test_rvh()->SendNavigate(2, landing_url);
1825 1825
1826 RunAllPendingInMessageLoop(); 1826 RunAllPendingInMessageLoop();
1827 EXPECT_TRUE(deleted2); 1827 EXPECT_TRUE(deleted2);
1828 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1828 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1829 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1829 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1830 NavigationEntry* entry = controller().GetActiveEntry(); 1830 NavigationEntry* entry = controller().GetVisibleEntry();
1831 ASSERT_TRUE(entry != NULL); 1831 ASSERT_TRUE(entry != NULL);
1832 EXPECT_TRUE(entry->GetURL() == landing_url); 1832 EXPECT_TRUE(entry->GetURL() == landing_url);
1833 EXPECT_EQ(2, controller().GetEntryCount()); 1833 EXPECT_EQ(2, controller().GetEntryCount());
1834 } 1834 }
1835 1835
1836 // Test that navigating away from an interstitial while it's loading cause it 1836 // Test that navigating away from an interstitial while it's loading cause it
1837 // not to show. 1837 // not to show.
1838 TEST_F(WebContentsImplTest, NavigateBeforeInterstitialShows) { 1838 TEST_F(WebContentsImplTest, NavigateBeforeInterstitialShows) {
1839 // Show an interstitial. 1839 // Show an interstitial.
1840 TestInterstitialPage::InterstitialState state = 1840 TestInterstitialPage::InterstitialState state =
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 TEST_F(WebContentsImplTest, PendingContents) { 2137 TEST_F(WebContentsImplTest, PendingContents) {
2138 scoped_ptr<TestWebContents> other_contents( 2138 scoped_ptr<TestWebContents> other_contents(
2139 static_cast<TestWebContents*>(CreateTestWebContents())); 2139 static_cast<TestWebContents*>(CreateTestWebContents()));
2140 contents()->AddPendingContents(other_contents.get()); 2140 contents()->AddPendingContents(other_contents.get());
2141 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2141 int route_id = other_contents->GetRenderViewHost()->GetRoutingID();
2142 other_contents.reset(); 2142 other_contents.reset();
2143 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); 2143 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id));
2144 } 2144 }
2145 2145
2146 } // namespace content 2146 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/web_contents/web_contents_view_aura_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698