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

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

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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 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> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 RenderFrameHost* initial_rfh = 99 RenderFrameHost* initial_rfh =
100 static_cast<WebContentsImpl*>(shell()->web_contents()) 100 static_cast<WebContentsImpl*>(shell()->web_contents())
101 ->GetFrameTree()->root()->current_frame_host(); 101 ->GetFrameTree()->root()->current_frame_host();
102 102
103 // Simulate clicking on a same-site link. 103 // Simulate clicking on a same-site link.
104 { 104 {
105 TestNavigationObserver observer(shell()->web_contents()); 105 TestNavigationObserver observer(shell()->web_contents());
106 GURL url(embedded_test_server()->GetURL("/title2.html")); 106 GURL url(embedded_test_server()->GetURL("/title2.html"));
107 bool success = false; 107 bool success = false;
108 EXPECT_TRUE(ExecuteScriptAndExtractBool( 108 EXPECT_TRUE(ExecuteScriptAndExtractBool(
109 shell()->web_contents(), 109 shell(), "window.domAutomationController.send(clickSameSiteLink());",
110 "window.domAutomationController.send(clickSameSiteLink());", &success)); 110 &success));
111 EXPECT_TRUE(success); 111 EXPECT_TRUE(success);
112 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 112 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
113 EXPECT_EQ(url, observer.last_navigation_url()); 113 EXPECT_EQ(url, observer.last_navigation_url());
114 EXPECT_TRUE(observer.last_navigation_succeeded()); 114 EXPECT_TRUE(observer.last_navigation_succeeded());
115 } 115 }
116 116
117 // The RenderFrameHost should not have changed. 117 // The RenderFrameHost should not have changed.
118 EXPECT_EQ(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents()) 118 EXPECT_EQ(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents())
119 ->GetFrameTree()->root()->current_frame_host()); 119 ->GetFrameTree()->root()->current_frame_host());
120 } 120 }
(...skipping 17 matching lines...) Expand all
138 138
139 // Simulate clicking on a cross-site link. 139 // Simulate clicking on a cross-site link.
140 { 140 {
141 TestNavigationObserver observer(shell()->web_contents()); 141 TestNavigationObserver observer(shell()->web_contents());
142 const char kReplacePortNumber[] = 142 const char kReplacePortNumber[] =
143 "window.domAutomationController.send(setPortNumber(%d));"; 143 "window.domAutomationController.send(setPortNumber(%d));";
144 uint16_t port_number = embedded_test_server()->port(); 144 uint16_t port_number = embedded_test_server()->port();
145 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); 145 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html");
146 bool success = false; 146 bool success = false;
147 EXPECT_TRUE(ExecuteScriptAndExtractBool( 147 EXPECT_TRUE(ExecuteScriptAndExtractBool(
148 shell()->web_contents(), 148 shell(), base::StringPrintf(kReplacePortNumber, port_number),
149 base::StringPrintf(kReplacePortNumber, port_number),
150 &success)); 149 &success));
151 success = false; 150 success = false;
152 EXPECT_TRUE(ExecuteScriptAndExtractBool( 151 EXPECT_TRUE(ExecuteScriptAndExtractBool(
153 shell()->web_contents(), 152 shell(), "window.domAutomationController.send(clickCrossSiteLink());",
154 "window.domAutomationController.send(clickCrossSiteLink());",
155 &success)); 153 &success));
156 EXPECT_TRUE(success); 154 EXPECT_TRUE(success);
157 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 155 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
158 EXPECT_EQ(url, observer.last_navigation_url()); 156 EXPECT_EQ(url, observer.last_navigation_url());
159 EXPECT_TRUE(observer.last_navigation_succeeded()); 157 EXPECT_TRUE(observer.last_navigation_succeeded());
160 } 158 }
161 159
162 // The RenderFrameHost should not have changed unless site-per-process is 160 // The RenderFrameHost should not have changed unless site-per-process is
163 // enabled. 161 // enabled.
164 if (AreAllSitesIsolatedForTesting()) { 162 if (AreAllSitesIsolatedForTesting()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Original page shouldn't navigate away. 265 // Original page shouldn't navigate away.
268 EXPECT_EQ(kUrl, shell()->web_contents()->GetURL()); 266 EXPECT_EQ(kUrl, shell()->web_contents()->GetURL());
269 EXPECT_FALSE(shell() 267 EXPECT_FALSE(shell()
270 ->web_contents() 268 ->web_contents()
271 ->GetController() 269 ->GetController()
272 .GetLastCommittedEntry() 270 .GetLastCommittedEntry()
273 ->IsViewSourceMode()); 271 ->IsViewSourceMode());
274 } 272 }
275 273
276 } // namespace content 274 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698