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