Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2664 EXPECT_EQ(frame_url_b, | 2664 EXPECT_EQ(frame_url_b, |
| 2665 entry4->root_node()->children[0]->frame_entry->url()); | 2665 entry4->root_node()->children[0]->frame_entry->url()); |
| 2666 EXPECT_EQ( | 2666 EXPECT_EQ( |
| 2667 frame_url_c, | 2667 frame_url_c, |
| 2668 entry4->root_node()->children[0]->children[0]->frame_entry->url()); | 2668 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2669 } else { | 2669 } else { |
| 2670 // There are no subframe FrameNavigationEntries by default. | 2670 // There are no subframe FrameNavigationEntries by default. |
| 2671 EXPECT_EQ(0U, entry4->root_node()->children.size()); | 2671 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
| 2672 } | 2672 } |
| 2673 | 2673 |
| 2674 // Remember the DSNs for later. | |
| 2675 int64_t root_dsn = | |
| 2676 entry4->root_node()->frame_entry->document_sequence_number(); | |
| 2677 int64_t frame_b_dsn = -1; | |
| 2678 int64_t frame_c_dsn = -1; | |
| 2679 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | |
| 2680 frame_b_dsn = entry4->root_node() | |
| 2681 ->children[0] | |
| 2682 ->frame_entry->document_sequence_number(); | |
| 2683 frame_c_dsn = entry4->root_node() | |
| 2684 ->children[0] | |
| 2685 ->children[0] | |
| 2686 ->frame_entry->document_sequence_number(); | |
| 2687 } | |
| 2688 | |
| 2674 // 5. Navigate main frame cross-site, destroying the frames. | 2689 // 5. Navigate main frame cross-site, destroying the frames. |
| 2675 GURL main_url_d(embedded_test_server()->GetURL( | 2690 GURL main_url_d(embedded_test_server()->GetURL( |
| 2676 "d.com", "/navigation_controller/simple_page_2.html")); | 2691 "d.com", "/navigation_controller/simple_page_2.html")); |
| 2677 NavigateToURL(shell(), main_url_d); | 2692 NavigateToURL(shell(), main_url_d); |
| 2678 ASSERT_EQ(0U, root->child_count()); | 2693 ASSERT_EQ(0U, root->child_count()); |
| 2679 EXPECT_EQ(main_url_d, root->current_url()); | 2694 EXPECT_EQ(main_url_d, root->current_url()); |
| 2680 | 2695 |
| 2681 EXPECT_EQ(5, controller.GetEntryCount()); | 2696 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2682 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 2697 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
| 2683 NavigationEntryImpl* entry5 = controller.GetLastCommittedEntry(); | 2698 NavigationEntryImpl* entry5 = controller.GetLastCommittedEntry(); |
| 2684 EXPECT_EQ(0U, entry5->root_node()->children.size()); | 2699 EXPECT_EQ(0U, entry5->root_node()->children.size()); |
| 2685 | 2700 |
| 2686 // 6. Go back, recreating the iframe and its nested iframe. | 2701 // 6. Go back, recreating the iframe and its nested iframe. |
| 2687 { | 2702 { |
| 2688 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2703 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2689 shell()->web_contents()->GetController().GoBack(); | 2704 shell()->web_contents()->GetController().GoBack(); |
| 2690 back_load_observer.Wait(); | 2705 back_load_observer.Wait(); |
| 2691 } | 2706 } |
| 2692 ASSERT_EQ(1U, root->child_count()); | 2707 ASSERT_EQ(1U, root->child_count()); |
| 2693 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 2708 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
| 2694 EXPECT_EQ(main_url_a, root->current_url()); | 2709 EXPECT_EQ(main_url_a, root->current_url()); |
| 2695 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 2710 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2696 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); | 2711 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); |
| 2697 | 2712 |
| 2698 EXPECT_EQ(5, controller.GetEntryCount()); | 2713 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2699 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2714 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2700 EXPECT_EQ(entry4, controller.GetLastCommittedEntry()); | 2715 EXPECT_EQ(entry4, controller.GetLastCommittedEntry()); |
| 2701 | 2716 |
| 2717 // The main frame should not have changed its DSN. | |
| 2718 EXPECT_EQ(root_dsn, | |
| 2719 entry4->root_node()->frame_entry->document_sequence_number()); | |
| 2720 | |
| 2702 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2721 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2703 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2722 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2704 // The entry should have FrameNavigationEntries for the subframes. | 2723 // The entry should have FrameNavigationEntries for the subframes. |
| 2705 ASSERT_EQ(1U, entry4->root_node()->children.size()); | 2724 ASSERT_EQ(1U, entry4->root_node()->children.size()); |
| 2706 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); | 2725 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); |
| 2707 EXPECT_EQ(frame_url_b, | 2726 EXPECT_EQ(frame_url_b, |
| 2708 entry4->root_node()->children[0]->frame_entry->url()); | 2727 entry4->root_node()->children[0]->frame_entry->url()); |
| 2709 EXPECT_EQ( | 2728 EXPECT_EQ( |
| 2710 frame_url_c, | 2729 frame_url_c, |
| 2711 entry4->root_node()->children[0]->children[0]->frame_entry->url()); | 2730 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2731 | |
| 2732 // The subframes should not have changed their DSNs. | |
| 2733 // See https://crbug.com/628286. | |
| 2734 EXPECT_EQ(frame_b_dsn, entry4->root_node() | |
| 2735 ->children[0] | |
| 2736 ->frame_entry->document_sequence_number()); | |
| 2737 EXPECT_EQ(frame_c_dsn, entry4->root_node() | |
| 2738 ->children[0] | |
| 2739 ->children[0] | |
| 2740 ->frame_entry->document_sequence_number()); | |
|
alexmos
2016/07/14 23:03:27
Makes sense - without the fix, these DSNs were fre
Charlie Reis
2016/07/14 23:25:01
Exactly.
| |
| 2712 } else { | 2741 } else { |
| 2713 // There are no subframe FrameNavigationEntries by default. | 2742 // There are no subframe FrameNavigationEntries by default. |
| 2714 EXPECT_EQ(0U, entry4->root_node()->children.size()); | 2743 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
| 2715 } | 2744 } |
| 2716 | 2745 |
| 2717 // Inject a JS value so that we can check for it later. | 2746 // Inject a JS value so that we can check for it later. |
| 2718 EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); | 2747 EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); |
| 2719 | 2748 |
| 2720 // 7. Go back again, to the data URL in the nested iframe. | 2749 // 7. Go back again, to the data URL in the nested iframe. |
| 2721 { | 2750 { |
| (...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4922 std::string body; | 4951 std::string body; |
| 4923 EXPECT_TRUE(ExecuteScriptAndExtractString( | 4952 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 4924 shell()->web_contents(), | 4953 shell()->web_contents(), |
| 4925 "window.domAutomationController.send(" | 4954 "window.domAutomationController.send(" |
| 4926 "document.getElementsByTagName('pre')[0].innerText);", | 4955 "document.getElementsByTagName('pre')[0].innerText);", |
| 4927 &body)); | 4956 &body)); |
| 4928 EXPECT_EQ("text=value\n", body); | 4957 EXPECT_EQ("text=value\n", body); |
| 4929 } | 4958 } |
| 4930 | 4959 |
| 4931 } // namespace content | 4960 } // namespace content |
| OLD | NEW |