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 <stdint.h> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" |
7 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/frame_host/frame_navigation_entry.h" | 12 #include "content/browser/frame_host/frame_navigation_entry.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
11 #include "content/browser/frame_host/navigation_controller_impl.h" | 14 #include "content/browser/frame_host/navigation_controller_impl.h" |
12 #include "content/browser/frame_host/navigation_entry_impl.h" | 15 #include "content/browser/frame_host/navigation_entry_impl.h" |
13 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
14 #include "content/common/site_isolation_policy.h" | 17 #include "content/common/site_isolation_policy.h" |
15 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/resource_controller.h" | 19 #include "content/public/browser/resource_controller.h" |
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2617 // 1. Navigate the main frame. | 2620 // 1. Navigate the main frame. |
2618 GURL url(embedded_test_server()->GetURL( | 2621 GURL url(embedded_test_server()->GetURL( |
2619 "/navigation_controller/page_with_links.html")); | 2622 "/navigation_controller/page_with_links.html")); |
2620 NavigateToURL(shell(), url); | 2623 NavigateToURL(shell(), url); |
2621 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2624 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
2622 ->GetFrameTree() | 2625 ->GetFrameTree() |
2623 ->root(); | 2626 ->root(); |
2624 | 2627 |
2625 FrameNavigationEntry* frame_entry = | 2628 FrameNavigationEntry* frame_entry = |
2626 controller.GetLastCommittedEntry()->GetFrameEntry(root); | 2629 controller.GetLastCommittedEntry()->GetFrameEntry(root); |
2627 int64 isn_1 = frame_entry->item_sequence_number(); | 2630 int64_t isn_1 = frame_entry->item_sequence_number(); |
2628 int64 dsn_1 = frame_entry->document_sequence_number(); | 2631 int64_t dsn_1 = frame_entry->document_sequence_number(); |
2629 EXPECT_NE(-1, isn_1); | 2632 EXPECT_NE(-1, isn_1); |
2630 EXPECT_NE(-1, dsn_1); | 2633 EXPECT_NE(-1, dsn_1); |
2631 | 2634 |
2632 // 2. Do an in-page fragment navigation. | 2635 // 2. Do an in-page fragment navigation. |
2633 std::string script = "document.getElementById('fraglink').click()"; | 2636 std::string script = "document.getElementById('fraglink').click()"; |
2634 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 2637 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
2635 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 2638 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
2636 | 2639 |
2637 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); | 2640 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); |
2638 int64 isn_2 = frame_entry->item_sequence_number(); | 2641 int64_t isn_2 = frame_entry->item_sequence_number(); |
2639 int64 dsn_2 = frame_entry->document_sequence_number(); | 2642 int64_t dsn_2 = frame_entry->document_sequence_number(); |
2640 EXPECT_NE(-1, isn_2); | 2643 EXPECT_NE(-1, isn_2); |
2641 EXPECT_NE(isn_1, isn_2); | 2644 EXPECT_NE(isn_1, isn_2); |
2642 EXPECT_EQ(dsn_1, dsn_2); | 2645 EXPECT_EQ(dsn_1, dsn_2); |
2643 | 2646 |
2644 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process. | 2647 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process. |
2645 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2648 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
2646 return; | 2649 return; |
2647 | 2650 |
2648 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. | 2651 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. |
2649 { | 2652 { |
2650 LoadCommittedCapturer capturer(shell()->web_contents()); | 2653 LoadCommittedCapturer capturer(shell()->web_contents()); |
2651 std::string add_script = "var iframe = document.createElement('iframe');" | 2654 std::string add_script = "var iframe = document.createElement('iframe');" |
2652 "iframe.src = '" + url.spec() + "';" | 2655 "iframe.src = '" + url.spec() + "';" |
2653 "document.body.appendChild(iframe);"; | 2656 "document.body.appendChild(iframe);"; |
2654 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), add_script)); | 2657 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), add_script)); |
2655 capturer.Wait(); | 2658 capturer.Wait(); |
2656 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 2659 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
2657 } | 2660 } |
2658 | 2661 |
2659 // The root FrameNavigationEntry hasn't changed. | 2662 // The root FrameNavigationEntry hasn't changed. |
2660 EXPECT_EQ(frame_entry, | 2663 EXPECT_EQ(frame_entry, |
2661 controller.GetLastCommittedEntry()->GetFrameEntry(root)); | 2664 controller.GetLastCommittedEntry()->GetFrameEntry(root)); |
2662 | 2665 |
2663 // We should have a unique ISN and DSN for the subframe entry. | 2666 // We should have a unique ISN and DSN for the subframe entry. |
2664 FrameTreeNode* subframe = root->child_at(0); | 2667 FrameTreeNode* subframe = root->child_at(0); |
2665 FrameNavigationEntry* subframe_entry = | 2668 FrameNavigationEntry* subframe_entry = |
2666 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 2669 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
2667 int64 isn_3 = subframe_entry->item_sequence_number(); | 2670 int64_t isn_3 = subframe_entry->item_sequence_number(); |
2668 int64 dsn_3 = subframe_entry->document_sequence_number(); | 2671 int64_t dsn_3 = subframe_entry->document_sequence_number(); |
2669 EXPECT_NE(-1, isn_2); | 2672 EXPECT_NE(-1, isn_2); |
2670 EXPECT_NE(isn_2, isn_3); | 2673 EXPECT_NE(isn_2, isn_3); |
2671 EXPECT_NE(dsn_2, dsn_3); | 2674 EXPECT_NE(dsn_2, dsn_3); |
2672 | 2675 |
2673 // 4. Do an in-page fragment navigation in the subframe. | 2676 // 4. Do an in-page fragment navigation in the subframe. |
2674 EXPECT_TRUE(content::ExecuteScript(subframe->current_frame_host(), script)); | 2677 EXPECT_TRUE(content::ExecuteScript(subframe->current_frame_host(), script)); |
2675 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 2678 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
2676 | 2679 |
2677 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 2680 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
2678 int64 isn_4 = subframe_entry->item_sequence_number(); | 2681 int64_t isn_4 = subframe_entry->item_sequence_number(); |
2679 int64 dsn_4 = subframe_entry->document_sequence_number(); | 2682 int64_t dsn_4 = subframe_entry->document_sequence_number(); |
2680 EXPECT_NE(-1, isn_4); | 2683 EXPECT_NE(-1, isn_4); |
2681 EXPECT_NE(isn_3, isn_4); | 2684 EXPECT_NE(isn_3, isn_4); |
2682 EXPECT_EQ(dsn_3, dsn_4); | 2685 EXPECT_EQ(dsn_3, dsn_4); |
2683 } | 2686 } |
2684 | 2687 |
2685 // Support a set of tests that isolate only a subset of sites with | 2688 // Support a set of tests that isolate only a subset of sites with |
2686 // out-of-process iframes (OOPIFs). | 2689 // out-of-process iframes (OOPIFs). |
2687 class NavigationControllerOopifBrowserTest | 2690 class NavigationControllerOopifBrowserTest |
2688 : public NavigationControllerBrowserTest { | 2691 : public NavigationControllerBrowserTest { |
2689 public: | 2692 public: |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3182 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 3185 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
3183 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 3186 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
3184 } | 3187 } |
3185 | 3188 |
3186 // Make sure the renderer is still alive. | 3189 // Make sure the renderer is still alive. |
3187 EXPECT_TRUE( | 3190 EXPECT_TRUE( |
3188 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 3191 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
3189 } | 3192 } |
3190 | 3193 |
3191 } // namespace content | 3194 } // namespace content |
OLD | NEW |