OLD | NEW |
---|---|
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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2465 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2465 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2466 params.page_id = 1; | 2466 params.page_id = 1; |
2467 params.nav_entry_id = 0; | 2467 params.nav_entry_id = 0; |
2468 params.frame_unique_name = unique_name; | 2468 params.frame_unique_name = unique_name; |
2469 params.did_create_new_entry = false; | 2469 params.did_create_new_entry = false; |
2470 params.url = subframe_url; | 2470 params.url = subframe_url; |
2471 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2471 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2472 params.should_update_history = false; | 2472 params.should_update_history = false; |
2473 params.gesture = NavigationGestureUser; | 2473 params.gesture = NavigationGestureUser; |
2474 params.method = "GET"; | 2474 params.method = "GET"; |
2475 params.page_state = PageState::CreateFromURL(subframe_url); | 2475 params.page_state = TestRenderFrameHost::CreatePageStateForURL( |
2476 subframe_url, item_sequence_number1, 0); | |
2476 params.item_sequence_number = item_sequence_number1; | 2477 params.item_sequence_number = item_sequence_number1; |
2477 | 2478 |
2478 // Navigating should do nothing. | 2479 // Navigating should do nothing. |
2479 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); | 2480 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); |
2480 subframe->PrepareForCommit(); | 2481 subframe->PrepareForCommit(); |
2481 subframe->SendNavigateWithParams(¶ms); | 2482 subframe->SendNavigateWithParams(¶ms); |
2482 | 2483 |
2483 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2484 // In UseSubframeNavigationEntries mode, we notify of a PageState update to |
2484 // the entry here rather than during UpdateState. | 2485 // the entry here rather than during UpdateState. |
2485 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2486 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
2486 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | 2487 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
2487 else | 2488 else |
2488 EXPECT_EQ(0U, notifications.size()); | 2489 EXPECT_EQ(0U, notifications.size()); |
2489 } | 2490 } |
2490 | 2491 |
2491 // First manual subframe navigation. | 2492 // First manual subframe navigation. |
2492 const GURL url2("http://foo2"); | 2493 const GURL url2("http://foo2"); |
2493 int64_t item_sequence_number2 = base::Time::Now().ToDoubleT() * 1000000; | 2494 int64_t item_sequence_number2 = base::Time::Now().ToDoubleT() * 1000000; |
2494 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2495 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2495 params.page_id = 2; | 2496 params.page_id = 2; |
2496 params.nav_entry_id = 0; | 2497 params.nav_entry_id = 0; |
2497 params.frame_unique_name = unique_name; | 2498 params.frame_unique_name = unique_name; |
2498 params.did_create_new_entry = true; | 2499 params.did_create_new_entry = true; |
2499 params.url = url2; | 2500 params.url = url2; |
2500 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2501 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2501 params.should_update_history = false; | 2502 params.should_update_history = false; |
2502 params.gesture = NavigationGestureUser; | 2503 params.gesture = NavigationGestureUser; |
2503 params.method = "GET"; | 2504 params.method = "GET"; |
2504 params.page_state = PageState::CreateFromURL(url2); | 2505 params.page_state = TestRenderFrameHost::CreatePageStateForURL( |
2506 url2, item_sequence_number2, 0); | |
nasko
2016/09/07 23:21:59
The document sequence number should be different t
ananta
2016/09/07 23:58:44
Done.
| |
2505 params.item_sequence_number = item_sequence_number2; | 2507 params.item_sequence_number = item_sequence_number2; |
2506 | 2508 |
2507 // This should generate a new entry. | 2509 // This should generate a new entry. |
2508 subframe->SendRendererInitiatedNavigationRequest(url2, false); | 2510 subframe->SendRendererInitiatedNavigationRequest(url2, false); |
2509 subframe->PrepareForCommit(); | 2511 subframe->PrepareForCommit(); |
2510 subframe->SendNavigateWithParams(¶ms); | 2512 subframe->SendNavigateWithParams(¶ms); |
2511 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2513 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
2512 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2514 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2513 navigation_entry_committed_counter_ = 0; | 2515 navigation_entry_committed_counter_ = 0; |
2514 EXPECT_EQ(2, controller.GetEntryCount()); | 2516 EXPECT_EQ(2, controller.GetEntryCount()); |
(...skipping 10 matching lines...) Expand all Loading... | |
2525 | 2527 |
2526 | 2528 |
2527 // Second manual subframe navigation should also make a new entry. | 2529 // Second manual subframe navigation should also make a new entry. |
2528 const GURL url3("http://foo3"); | 2530 const GURL url3("http://foo3"); |
2529 params.page_id = 3; | 2531 params.page_id = 3; |
2530 params.nav_entry_id = 0; | 2532 params.nav_entry_id = 0; |
2531 params.frame_unique_name = unique_name; | 2533 params.frame_unique_name = unique_name; |
2532 params.did_create_new_entry = true; | 2534 params.did_create_new_entry = true; |
2533 params.url = url3; | 2535 params.url = url3; |
2534 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2536 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2535 params.page_state = PageState::CreateFromURL(url3); | |
2536 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; | 2537 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; |
2538 params.page_state = TestRenderFrameHost::CreatePageStateForURL( | |
2539 url3, params.item_sequence_number, 0); | |
nasko
2016/09/07 23:21:59
Same here. Document number cannot be the same.
ananta
2016/09/07 23:58:44
Done.
| |
2537 subframe->SendRendererInitiatedNavigationRequest(url3, false); | 2540 subframe->SendRendererInitiatedNavigationRequest(url3, false); |
2538 subframe->PrepareForCommit(); | 2541 subframe->PrepareForCommit(); |
2539 subframe->SendNavigateWithParams(¶ms); | 2542 subframe->SendNavigateWithParams(¶ms); |
2540 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2543 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2541 navigation_entry_committed_counter_ = 0; | 2544 navigation_entry_committed_counter_ = 0; |
2542 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2545 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
2543 EXPECT_EQ(3, controller.GetEntryCount()); | 2546 EXPECT_EQ(3, controller.GetEntryCount()); |
2544 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2547 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
2545 | 2548 |
2546 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2549 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2547 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2550 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2548 // The entry should have a subframe FrameNavigationEntry. | 2551 // The entry should have a subframe FrameNavigationEntry. |
2549 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2552 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2550 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); | 2553 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); |
2551 } else { | 2554 } else { |
2552 // There are no subframe FrameNavigationEntries by default. | 2555 // There are no subframe FrameNavigationEntries by default. |
2553 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2556 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
2554 } | 2557 } |
2555 | 2558 |
2556 // Go back one. | 2559 // Go back one. |
2557 controller.GoBack(); | 2560 controller.GoBack(); |
2558 params.page_id = 2; | 2561 params.page_id = 2; |
2559 params.nav_entry_id = entry2->GetUniqueID(); | 2562 params.nav_entry_id = entry2->GetUniqueID(); |
2560 params.frame_unique_name = unique_name; | 2563 params.frame_unique_name = unique_name; |
2561 params.did_create_new_entry = false; | 2564 params.did_create_new_entry = false; |
2562 params.url = url2; | 2565 params.url = url2; |
2563 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2566 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2564 params.page_state = PageState::CreateFromURL(url2); | 2567 params.page_state = TestRenderFrameHost::CreatePageStateForURL( |
2568 url2, item_sequence_number2, 0); | |
2565 params.item_sequence_number = item_sequence_number2; | 2569 params.item_sequence_number = item_sequence_number2; |
2566 subframe->PrepareForCommit(); | 2570 subframe->PrepareForCommit(); |
2567 subframe->SendNavigateWithParams(¶ms); | 2571 subframe->SendNavigateWithParams(¶ms); |
2568 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2572 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2569 navigation_entry_committed_counter_ = 0; | 2573 navigation_entry_committed_counter_ = 0; |
2570 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2574 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2571 EXPECT_EQ(3, controller.GetEntryCount()); | 2575 EXPECT_EQ(3, controller.GetEntryCount()); |
2572 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 2576 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
2573 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2577 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2574 EXPECT_FALSE(controller.GetPendingEntry()); | 2578 EXPECT_FALSE(controller.GetPendingEntry()); |
2575 | 2579 |
2576 // Go back one more. | 2580 // Go back one more. |
2577 controller.GoBack(); | 2581 controller.GoBack(); |
2578 params.page_id = 1; | 2582 params.page_id = 1; |
2579 params.nav_entry_id = entry1->GetUniqueID(); | 2583 params.nav_entry_id = entry1->GetUniqueID(); |
2580 params.frame_unique_name = unique_name; | 2584 params.frame_unique_name = unique_name; |
2581 params.did_create_new_entry = false; | 2585 params.did_create_new_entry = false; |
2582 params.url = subframe_url; | 2586 params.url = subframe_url; |
2583 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2587 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2584 params.page_state = PageState::CreateFromURL(subframe_url); | 2588 params.page_state = TestRenderFrameHost::CreatePageStateForURL( |
2589 subframe_url, item_sequence_number1, 0); | |
2585 params.item_sequence_number = item_sequence_number1; | 2590 params.item_sequence_number = item_sequence_number1; |
2586 subframe->PrepareForCommit(); | 2591 subframe->PrepareForCommit(); |
2587 subframe->SendNavigateWithParams(¶ms); | 2592 subframe->SendNavigateWithParams(¶ms); |
2588 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2593 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2589 navigation_entry_committed_counter_ = 0; | 2594 navigation_entry_committed_counter_ = 0; |
2590 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 2595 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
2591 EXPECT_EQ(3, controller.GetEntryCount()); | 2596 EXPECT_EQ(3, controller.GetEntryCount()); |
2592 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 2597 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
2593 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2598 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2594 EXPECT_FALSE(controller.GetPendingEntry()); | 2599 EXPECT_FALSE(controller.GetPendingEntry()); |
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5318 // means that occasionally a navigation conflict will end up with one entry | 5323 // means that occasionally a navigation conflict will end up with one entry |
5319 // bubbling to the end of the entry list, but that's the least-bad option. | 5324 // bubbling to the end of the entry list, but that's the least-bad option. |
5320 EXPECT_EQ(3, controller.GetEntryCount()); | 5325 EXPECT_EQ(3, controller.GetEntryCount()); |
5321 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 5326 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
5322 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); | 5327 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); |
5323 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); | 5328 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); |
5324 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); | 5329 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
5325 } | 5330 } |
5326 | 5331 |
5327 } // namespace content | 5332 } // namespace content |
OLD | NEW |