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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: Rebase again. Created 3 years, 9 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
OLDNEW
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
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 9785 matching lines...) Expand 10 before | Expand all | Expand 10 after
9899 root->child_at(0)->current_frame_host()->GetSiteInstance()); 9905 root->child_at(0)->current_frame_host()->GetSiteInstance());
9900 9906
9901 // Try the same navigation, but use the browser-initiated path. 9907 // Try the same navigation, but use the browser-initiated path.
9902 NavigateFrameToURL(root->child_at(0), frame_url); 9908 NavigateFrameToURL(root->child_at(0), frame_url);
9903 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); 9909 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host());
9904 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); 9910 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url);
9905 EXPECT_EQ(b_site_instance, 9911 EXPECT_EQ(b_site_instance,
9906 root->child_at(0)->current_frame_host()->GetSiteInstance()); 9912 root->child_at(0)->current_frame_host()->GetSiteInstance());
9907 } 9913 }
9908 9914
9915 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
9916 FrameSwapPreservesUniqueName) {
9917 GURL main_url(embedded_test_server()->GetURL(
9918 "a.com", "/cross_site_iframe_factory.html?a(a)"));
9919 ASSERT_TRUE(NavigateToURL(shell(), main_url));
9920
9921 // Navigate the subframe cross-site…
9922 {
9923 GURL url(embedded_test_server()->GetURL("b.com", "/title1.html"));
9924 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url));
9925 }
9926 // and then same-site…
9927 {
9928 GURL url(embedded_test_server()->GetURL("a.com", "/title1.html"));
9929 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url));
9930 }
9931 // and cross-site once more.
9932 {
9933 GURL url(embedded_test_server()->GetURL("b.com", "/title1.html"));
9934 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", url));
9935 }
9936
9937 // Inspect the navigation entries and make sure that the navigation target
9938 // remained constant across frame swaps.
9939 const auto& controller = static_cast<const NavigationControllerImpl&>(
9940 shell()->web_contents()->GetController());
9941 EXPECT_EQ(4, controller.GetEntryCount());
9942
9943 std::set<std::string> names;
9944 for (int i = 0; i < controller.GetEntryCount(); ++i) {
9945 NavigationEntryImpl::TreeNode* root =
9946 controller.GetEntryAtIndex(i)->root_node();
9947 ASSERT_EQ(1U, root->children.size());
9948 names.insert(root->children[0]->frame_entry->frame_unique_name());
9949 }
9950
9951 // More than one entry in the set means that the subframe frame navigation
9952 // entries didn't have a consistent unique name. This will break history
9953 // navigations =(
9954 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!";
9955 }
9956
9909 } // namespace content 9957 } // namespace content
OLDNEW
« no previous file with comments | « components/printing/renderer/print_web_view_helper.cc ('k') | content/public/test/test_runner_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698