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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 143183009: When cross-site navigations are cancelled, delete the request being transferred (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: *Really* remove AbortTransfer Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/navigation_controller_impl.h" 6 #include "content/browser/frame_host/navigation_controller_impl.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/frame_host/navigator.h" 8 #include "content/browser/frame_host/navigator.h"
9 #include "content/browser/frame_host/render_frame_host_manager.h" 9 #include "content/browser/frame_host/render_frame_host_manager.h"
10 #include "content/browser/renderer_host/cross_site_transferring_request.h"
10 #include "content/browser/site_instance_impl.h" 11 #include "content/browser/site_instance_impl.h"
11 #include "content/browser/webui/web_ui_controller_factory_registry.h" 12 #include "content/browser/webui/web_ui_controller_factory_registry.h"
12 #include "content/common/frame_messages.h" 13 #include "content/common/frame_messages.h"
13 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_widget_host_iterator.h" 20 #include "content/public/browser/render_widget_host_iterator.h"
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 1388 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
1388 EXPECT_TRUE(contents()->cross_navigation_pending()); 1389 EXPECT_TRUE(contents()->cross_navigation_pending());
1389 TestRenderViewHost* rvh2 = 1390 TestRenderViewHost* rvh2 =
1390 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); 1391 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
1391 1392
1392 // Simulate rvh2's response, which leads to an unload request being sent to 1393 // Simulate rvh2's response, which leads to an unload request being sent to
1393 // rvh1. 1394 // rvh1.
1394 std::vector<GURL> url_chain; 1395 std::vector<GURL> url_chain;
1395 url_chain.push_back(GURL()); 1396 url_chain.push_back(GURL());
1396 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse( 1397 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1397 rvh2, GlobalRequestID(0, 0), false, url_chain, Referrer(), 1398 rvh2, GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1398 PAGE_TRANSITION_TYPED, 1, false); 1399 url_chain, Referrer(), PAGE_TRANSITION_TYPED, 1, false);
1399 EXPECT_TRUE(contents()->cross_navigation_pending()); 1400 EXPECT_TRUE(contents()->cross_navigation_pending());
1400 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK, 1401 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK,
1401 rvh1->rvh_state()); 1402 rvh1->rvh_state());
1402 1403
1403 // Simulate the swap out ack. 1404 // Simulate the swap out ack.
1404 rvh1->OnSwappedOut(false); 1405 rvh1->OnSwappedOut(false);
1405 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_COMMIT, rvh1->rvh_state()); 1406 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_COMMIT, rvh1->rvh_state());
1406 1407
1407 // The new page commits. 1408 // The new page commits.
1408 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED); 1409 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 1441 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
1441 EXPECT_TRUE(contents()->cross_navigation_pending()); 1442 EXPECT_TRUE(contents()->cross_navigation_pending());
1442 TestRenderViewHost* rvh2 = 1443 TestRenderViewHost* rvh2 =
1443 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); 1444 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
1444 1445
1445 // Simulate rvh2's response, which leads to an unload request being sent to 1446 // Simulate rvh2's response, which leads to an unload request being sent to
1446 // rvh1. 1447 // rvh1.
1447 std::vector<GURL> url_chain; 1448 std::vector<GURL> url_chain;
1448 url_chain.push_back(GURL()); 1449 url_chain.push_back(GURL());
1449 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse( 1450 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1450 rvh2, GlobalRequestID(0, 0), false, url_chain, Referrer(), 1451 rvh2, GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1451 PAGE_TRANSITION_TYPED, 1, false); 1452 url_chain, Referrer(), PAGE_TRANSITION_TYPED, 1, false);
1452 EXPECT_TRUE(contents()->cross_navigation_pending()); 1453 EXPECT_TRUE(contents()->cross_navigation_pending());
1453 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK, 1454 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK,
1454 rvh1->rvh_state()); 1455 rvh1->rvh_state());
1455 1456
1456 // Simulate the swap out ack. 1457 // Simulate the swap out ack.
1457 rvh1->OnSwappedOut(false); 1458 rvh1->OnSwappedOut(false);
1458 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_COMMIT, rvh1->rvh_state()); 1459 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_COMMIT, rvh1->rvh_state());
1459 1460
1460 // The new page commits. 1461 // The new page commits.
1461 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED); 1462 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED);
(...skipping 26 matching lines...) Expand all
1488 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 1489 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
1489 EXPECT_TRUE(contents()->cross_navigation_pending()); 1490 EXPECT_TRUE(contents()->cross_navigation_pending());
1490 TestRenderViewHost* rvh2 = 1491 TestRenderViewHost* rvh2 =
1491 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); 1492 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
1492 1493
1493 // Simulate rvh2's response, which leads to an unload request being sent to 1494 // Simulate rvh2's response, which leads to an unload request being sent to
1494 // rvh1. 1495 // rvh1.
1495 std::vector<GURL> url_chain; 1496 std::vector<GURL> url_chain;
1496 url_chain.push_back(GURL()); 1497 url_chain.push_back(GURL());
1497 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse( 1498 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1498 rvh2, GlobalRequestID(0, 0), false, url_chain, Referrer(), 1499 rvh2, GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1499 PAGE_TRANSITION_TYPED, 1, false); 1500 url_chain, Referrer(), PAGE_TRANSITION_TYPED, 1, false);
1500 EXPECT_TRUE(contents()->cross_navigation_pending()); 1501 EXPECT_TRUE(contents()->cross_navigation_pending());
1501 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK, 1502 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK,
1502 rvh1->rvh_state()); 1503 rvh1->rvh_state());
1503 1504
1504 // The new page commits. 1505 // The new page commits.
1505 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED); 1506 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED);
1506 EXPECT_FALSE(contents()->cross_navigation_pending()); 1507 EXPECT_FALSE(contents()->cross_navigation_pending());
1507 EXPECT_EQ(rvh2, rvh()); 1508 EXPECT_EQ(rvh2, rvh());
1508 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); 1509 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL);
1509 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh2->rvh_state()); 1510 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh2->rvh_state());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 1542 rvh1->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
1542 EXPECT_TRUE(contents()->cross_navigation_pending()); 1543 EXPECT_TRUE(contents()->cross_navigation_pending());
1543 TestRenderViewHost* rvh2 = 1544 TestRenderViewHost* rvh2 =
1544 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); 1545 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
1545 1546
1546 // Simulate rvh2's response, which leads to an unload request being sent to 1547 // Simulate rvh2's response, which leads to an unload request being sent to
1547 // rvh1. 1548 // rvh1.
1548 std::vector<GURL> url_chain; 1549 std::vector<GURL> url_chain;
1549 url_chain.push_back(GURL()); 1550 url_chain.push_back(GURL());
1550 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse( 1551 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1551 rvh2, GlobalRequestID(0, 0), false, url_chain, Referrer(), 1552 rvh2, GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1552 PAGE_TRANSITION_TYPED, 1, false); 1553 url_chain, Referrer(), PAGE_TRANSITION_TYPED, 1, false);
1553 EXPECT_TRUE(contents()->cross_navigation_pending()); 1554 EXPECT_TRUE(contents()->cross_navigation_pending());
1554 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK, 1555 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK,
1555 rvh1->rvh_state()); 1556 rvh1->rvh_state());
1556 1557
1557 // The new page commits. 1558 // The new page commits.
1558 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED); 1559 contents()->TestDidNavigate(rvh2, 1, kUrl2, PAGE_TRANSITION_TYPED);
1559 EXPECT_FALSE(contents()->cross_navigation_pending()); 1560 EXPECT_FALSE(contents()->cross_navigation_pending());
1560 EXPECT_EQ(rvh2, rvh()); 1561 EXPECT_EQ(rvh2, rvh());
1561 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); 1562 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL);
1562 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh2->rvh_state()); 1563 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh2->rvh_state());
1563 EXPECT_EQ(RenderViewHostImpl::STATE_PENDING_SWAP_OUT, rvh1->rvh_state()); 1564 EXPECT_EQ(RenderViewHostImpl::STATE_PENDING_SWAP_OUT, rvh1->rvh_state());
1564 1565
1565 // Simulate the swap out ack. 1566 // Simulate the swap out ack.
1566 rvh1->OnSwappedOut(false); 1567 rvh1->OnSwappedOut(false);
1567 1568
1568 // rvh1 should be swapped out. 1569 // rvh1 should be swapped out.
1569 EXPECT_FALSE(destruction_observer.rvh_deleted()); 1570 EXPECT_FALSE(destruction_observer.rvh_deleted());
1570 EXPECT_TRUE(rvh1->IsSwappedOut()); 1571 EXPECT_TRUE(rvh1->IsSwappedOut());
1571 } 1572 }
1572 1573
1573 } // namespace content 1574 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/browser/loader/cross_site_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698