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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <map> | 11 #include <map> |
12 #include <set> | |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/bind.h" | 15 #include "base/bind.h" |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
17 #include "base/location.h" | 18 #include "base/location.h" |
18 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
20 #include "base/sequenced_task_runner.h" | 21 #include "base/sequenced_task_runner.h" |
21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/pattern.h" | 23 #include "base/strings/pattern.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
25 #include "base/test/test_timeouts.h" | 26 #include "base/test/test_timeouts.h" |
26 #include "base/threading/sequenced_task_runner_handle.h" | 27 #include "base/threading/sequenced_task_runner_handle.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
28 #include "build/build_config.h" | 29 #include "build/build_config.h" |
29 #include "content/browser/frame_host/cross_process_frame_connector.h" | 30 #include "content/browser/frame_host/cross_process_frame_connector.h" |
31 #include "content/browser/frame_host/frame_navigation_entry.h" | |
30 #include "content/browser/frame_host/frame_tree.h" | 32 #include "content/browser/frame_host/frame_tree.h" |
31 #include "content/browser/frame_host/interstitial_page_impl.h" | 33 #include "content/browser/frame_host/interstitial_page_impl.h" |
34 #include "content/browser/frame_host/navigation_controller_impl.h" | |
35 #include "content/browser/frame_host/navigation_entry_impl.h" | |
32 #include "content/browser/frame_host/navigator.h" | 36 #include "content/browser/frame_host/navigator.h" |
33 #include "content/browser/frame_host/render_frame_proxy_host.h" | 37 #include "content/browser/frame_host/render_frame_proxy_host.h" |
34 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 38 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
35 #include "content/browser/gpu/compositor_util.h" | 39 #include "content/browser/gpu/compositor_util.h" |
36 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 40 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
37 #include "content/browser/renderer_host/input/input_router_impl.h" | 41 #include "content/browser/renderer_host/input/input_router_impl.h" |
38 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | 42 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
39 #include "content/browser/renderer_host/render_view_host_impl.h" | 43 #include "content/browser/renderer_host/render_view_host_impl.h" |
40 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 44 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
41 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 45 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 #endif | 98 #endif |
95 | 99 |
96 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
97 #include "base/android/jni_android.h" | 101 #include "base/android/jni_android.h" |
98 #include "base/android/jni_string.h" | 102 #include "base/android/jni_string.h" |
99 #include "base/android/scoped_java_ref.h" | 103 #include "base/android/scoped_java_ref.h" |
100 #include "content/browser/renderer_host/ime_adapter_android.h" | 104 #include "content/browser/renderer_host/ime_adapter_android.h" |
101 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 105 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
102 #endif | 106 #endif |
103 | 107 |
108 using ::testing::SizeIs; | |
109 | |
104 namespace content { | 110 namespace content { |
105 | 111 |
106 namespace { | 112 namespace { |
107 | 113 |
108 // Helper function to send a postMessage and wait for a reply message. The | 114 // Helper function to send a postMessage and wait for a reply message. The |
109 // |post_message_script| is executed on the |sender_ftn| frame, and the sender | 115 // |post_message_script| is executed on the |sender_ftn| frame, and the sender |
110 // frame is expected to post |reply_status| from the DOMAutomationController | 116 // frame is expected to post |reply_status| from the DOMAutomationController |
111 // when it receives a reply. | 117 // when it receives a reply. |
112 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, | 118 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, |
113 const std::string& post_message_script, | 119 const std::string& post_message_script, |
(...skipping 9463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9577 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 9583 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
9578 | 9584 |
9579 // Try the same navigation, but use the browser-initiated path. | 9585 // Try the same navigation, but use the browser-initiated path. |
9580 NavigateFrameToURL(root->child_at(0), frame_url); | 9586 NavigateFrameToURL(root->child_at(0), frame_url); |
9581 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); | 9587 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); |
9582 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); | 9588 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); |
9583 EXPECT_EQ(b_site_instance, | 9589 EXPECT_EQ(b_site_instance, |
9584 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 9590 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
9585 } | 9591 } |
9586 | 9592 |
9593 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
dcheng
2017/03/05 22:32:54
Here's the test that verifies unique names are pre
Charlie Reis
2017/03/20 20:11:38
Thanks!
| |
9594 FrameSwapPreservesUniqueName) { | |
9595 GURL main_url(embedded_test_server()->GetURL( | |
9596 "a.com", "/cross_site_iframe_factory.html?a(a)")); | |
9597 ASSERT_TRUE(NavigateToURL(shell(), main_url)); | |
9598 | |
9599 // Navigate the subframe cross-site… | |
9600 { | |
9601 GURL url(embedded_test_server()->GetURL("b.com", "/title1.html")); | |
9602 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url)); | |
dcheng
2017/03/05 22:32:54
Not sure if I should bother comparing the expected
Charlie Reis
2017/03/20 20:11:38
Yes, we have other tests for that in navigation_co
| |
9603 } | |
9604 // and then same-site… | |
9605 { | |
9606 GURL url(embedded_test_server()->GetURL("a.com", "/title1.html")); | |
9607 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url)); | |
9608 } | |
9609 // and cross-site once more. | |
9610 { | |
9611 GURL url(embedded_test_server()->GetURL("b.com", "/title1.html")); | |
9612 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url)); | |
9613 } | |
9614 | |
9615 // Inspect the navigation entries and make sure that the navigation target | |
9616 // remained constant across frame swaps. | |
9617 const auto& controller = static_cast<const NavigationControllerImpl&>( | |
9618 shell()->web_contents()->GetController()); | |
9619 EXPECT_EQ(4, controller.GetEntryCount()); | |
9620 | |
9621 std::set<std::string> names; | |
9622 for (int i = 0; i < controller.GetEntryCount(); ++i) { | |
9623 NavigationEntryImpl::TreeNode* root = | |
9624 controller.GetEntryAtIndex(i)->root_node(); | |
9625 ASSERT_EQ(1U, root->children.size()); | |
9626 names.insert(root->children[0]->frame_entry->frame_unique_name()); | |
9627 } | |
9628 | |
9629 // More than one entry in the set means that the subframe frame navigation | |
9630 // entries didn't have a consistent unique name. This will break history | |
9631 // navigations =( | |
9632 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | |
9633 } | |
9634 | |
9587 } // namespace content | 9635 } // namespace content |
OLD | NEW |