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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 // Start at a data URL so each extra navigation creates a navigation entry. | 162 // Start at a data URL so each extra navigation creates a navigation entry. |
163 // (The first navigation will silently be classified as AUTO_SUBFRAME.) | 163 // (The first navigation will silently be classified as AUTO_SUBFRAME.) |
164 // TODO(creis): This won't be necessary when we can wait for LOAD_STOP. | 164 // TODO(creis): This won't be necessary when we can wait for LOAD_STOP. |
165 void StartFrameAtDataURL() { | 165 void StartFrameAtDataURL() { |
166 std::string data_url_script = | 166 std::string data_url_script = |
167 "var iframes = document.getElementById('test');iframes.src=" | 167 "var iframes = document.getElementById('test');iframes.src=" |
168 "'data:text/html,dataurl';"; | 168 "'data:text/html,dataurl';"; |
169 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); | 169 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); |
170 } | 170 } |
171 | 171 |
172 bool NavigateIframeToURL(Shell* window, | 172 // Navigates a frame using JavaScript in the renderer process, causing a |
173 const GURL& url, | 173 // cross-process transfer navigation. |
174 std::string iframe_id) { | 174 bool NavigateFrameToURLInRenderer(Shell* window, |
175 const GURL& url, | |
176 std::string iframe_id) { | |
175 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe | 177 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe |
176 // navigations generate extra DidStartLoading and DidStopLoading messages. | 178 // navigations generate extra DidStartLoading and DidStopLoading messages. |
177 // Until we replace swappedout:// with frame proxies, we need to listen for | 179 // Until we replace swappedout:// with frame proxies, we need to listen for |
178 // something else. For now, we trigger NEW_SUBFRAME navigations and listen | 180 // something else. For now, we trigger NEW_SUBFRAME navigations and listen |
179 // for commit. | 181 // for commit. |
180 std::string script = base::StringPrintf( | 182 std::string script = base::StringPrintf( |
181 "setTimeout(\"" | 183 "setTimeout(\"" |
182 "var iframes = document.getElementById('%s');iframes.src='%s';" | 184 "var iframes = document.getElementById('%s');iframes.src='%s';" |
183 "\",0)", | 185 "\",0)", |
184 iframe_id.c_str(), url.spec().c_str()); | 186 iframe_id.c_str(), url.spec().c_str()); |
185 WindowedNotificationObserver load_observer( | 187 WindowedNotificationObserver load_observer( |
186 NOTIFICATION_NAV_ENTRY_COMMITTED, | 188 NOTIFICATION_NAV_ENTRY_COMMITTED, |
187 Source<NavigationController>( | 189 Source<NavigationController>( |
188 &window->web_contents()->GetController())); | 190 &window->web_contents()->GetController())); |
189 bool result = ExecuteScript(window->web_contents(), script); | 191 bool result = ExecuteScript(window->web_contents(), script); |
190 load_observer.Wait(); | 192 load_observer.Wait(); |
191 return result; | 193 return result; |
192 } | 194 } |
193 | 195 |
196 // Navigates a frame via the browser process, with no transfer. | |
197 void NavigateFrameToURL(WebContents* web_contents, | |
Charlie Reis
2014/03/21 23:24:33
This should make iframe tests a bit easier to writ
nasko
2014/03/22 04:07:17
Wouldn't WCO::DidNavigateAnyFrame help us here? We
| |
198 FrameTreeNode* node, | |
199 const GURL& url) { | |
200 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe | |
201 // navigations generate extra DidStartLoading and DidStopLoading messages. | |
202 // Until we replace swappedout:// with frame proxies, we need to listen for | |
203 // something else. For now, we listen for commit. | |
204 WindowedNotificationObserver load_observer( | |
205 NOTIFICATION_NAV_ENTRY_COMMITTED, | |
206 Source<NavigationController>( | |
207 &web_contents->GetController())); | |
208 NavigationController::LoadURLParams params(url); | |
209 params.transition_type = PageTransitionFromInt(PAGE_TRANSITION_LINK); | |
210 params.frame_tree_node_id = node->frame_tree_node_id(); | |
211 web_contents->GetController().LoadURLWithParams(params); | |
212 load_observer.Wait(); | |
213 } | |
214 | |
194 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 215 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
195 command_line->AppendSwitch(switches::kSitePerProcess); | 216 command_line->AppendSwitch(switches::kSitePerProcess); |
196 | 217 |
197 // TODO(creis): Remove this when GTK is no longer a supported platform. | 218 // TODO(creis): Remove this when GTK is no longer a supported platform. |
198 command_line->AppendSwitch(switches::kForceCompositingMode); | 219 command_line->AppendSwitch(switches::kForceCompositingMode); |
199 } | 220 } |
200 }; | 221 }; |
201 | 222 |
202 // Ensure that we can complete a cross-process subframe navigation. | 223 // Ensure that we can complete a cross-process subframe navigation. |
203 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 224 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
204 host_resolver()->AddRule("*", "127.0.0.1"); | 225 host_resolver()->AddRule("*", "127.0.0.1"); |
205 ASSERT_TRUE(test_server()->Start()); | 226 ASSERT_TRUE(test_server()->Start()); |
206 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 227 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
207 NavigateToURL(shell(), main_url); | 228 NavigateToURL(shell(), main_url); |
208 | 229 |
209 StartFrameAtDataURL(); | 230 StartFrameAtDataURL(); |
210 | 231 |
211 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 232 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
212 | 233 |
213 // Load same-site page into iframe. | 234 // Load same-site page into iframe. |
214 GURL http_url(test_server()->GetURL("files/title1.html")); | 235 GURL http_url(test_server()->GetURL("files/title1.html")); |
215 EXPECT_TRUE(NavigateIframeToURL(shell(), http_url, "test")); | 236 EXPECT_TRUE(NavigateFrameToURLInRenderer(shell(), http_url, "test")); |
216 EXPECT_EQ(http_url, observer.navigation_url()); | 237 EXPECT_EQ(http_url, observer.navigation_url()); |
217 EXPECT_TRUE(observer.navigation_succeeded()); | 238 EXPECT_TRUE(observer.navigation_succeeded()); |
218 | 239 |
219 // These must stay in scope with replace_host. | |
220 GURL::Replacements replace_host; | |
221 std::string foo_com("foo.com"); | |
222 | |
223 // Load cross-site page into iframe. | |
224 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | |
225 replace_host.SetHostStr(foo_com); | |
226 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | |
227 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); | |
228 EXPECT_EQ(cross_site_url, observer.navigation_url()); | |
229 EXPECT_TRUE(observer.navigation_succeeded()); | |
230 | |
231 // Ensure that we have created a new process for the subframe. | |
232 FrameTreeNode* root = | 240 FrameTreeNode* root = |
233 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 241 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
234 GetFrameTree()->root(); | 242 GetFrameTree()->root(); |
235 ASSERT_EQ(1U, root->child_count()); | 243 ASSERT_EQ(1U, root->child_count()); |
236 FrameTreeNode* child = root->child_at(0); | 244 FrameTreeNode* child = root->child_at(0); |
237 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 245 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
238 child->current_frame_host()->render_view_host()); | 246 child->current_frame_host()->GetSiteInstance()); |
239 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 247 |
240 child->current_frame_host()->render_view_host()->GetSiteInstance()); | 248 // These must stay in scope with replace_host. |
241 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), | 249 GURL::Replacements replace_host; |
242 child->current_frame_host()->GetProcess()); | 250 std::string foo_com("foo.com"); |
251 std::string bar_com("bar.com"); | |
252 | |
253 // Load cross-site page into iframe. | |
254 GURL foo_url(test_server()->GetURL("files/title2.html")); | |
255 replace_host.SetHostStr(foo_com); | |
256 foo_url = foo_url.ReplaceComponents(replace_host); | |
257 EXPECT_TRUE(NavigateFrameToURLInRenderer(shell(), foo_url, "test")); | |
258 EXPECT_EQ(foo_url, observer.navigation_url()); | |
259 EXPECT_TRUE(observer.navigation_succeeded()); | |
260 | |
261 // Ensure that we have created a new process for the subframe. | |
262 RenderFrameHost* foo_rfh = child->current_frame_host(); | |
263 EXPECT_NE(shell()->web_contents()->GetMainFrame(), foo_rfh); | |
264 int foo_site_instance_id = foo_rfh->GetSiteInstance()->GetId(); | |
265 EXPECT_NE(shell()->web_contents()->GetSiteInstance()->GetId(), | |
266 foo_site_instance_id); | |
267 int foo_process_id = foo_rfh->GetProcess()->GetID(); | |
268 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost()->GetID(), | |
269 foo_process_id); | |
270 | |
271 // Load another cross-site page into the same iframe. | |
Charlie Reis
2014/03/21 23:24:33
This second navigation tests the beforeunload cras
| |
272 GURL bar_url(test_server()->GetURL("files/title1.html")); | |
273 replace_host.SetHostStr(bar_com); | |
274 bar_url = bar_url.ReplaceComponents(replace_host); | |
275 NavigateFrameToURL(shell()->web_contents(), child, bar_url); | |
276 EXPECT_EQ(bar_url, observer.navigation_url()); | |
277 EXPECT_TRUE(observer.navigation_succeeded()); | |
278 | |
279 // Ensure the SiteInstance and process swapped. | |
280 RenderFrameHost* bar_rfh = child->current_frame_host(); | |
281 int bar_site_instance_id = bar_rfh->GetSiteInstance()->GetId(); | |
282 EXPECT_NE(foo_site_instance_id, bar_site_instance_id); | |
283 EXPECT_NE(shell()->web_contents()->GetSiteInstance()->GetId(), | |
284 bar_site_instance_id); | |
285 int bar_process_id = bar_rfh->GetProcess()->GetID(); | |
286 EXPECT_NE(foo_process_id, bar_process_id); | |
287 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost()->GetID(), | |
288 bar_process_id); | |
243 } | 289 } |
244 | 290 |
245 // Crash a subframe and ensures its children are cleared from the FrameTree. | 291 // Crash a subframe and ensures its children are cleared from the FrameTree. |
246 // See http://crbug.com/338508. | 292 // See http://crbug.com/338508. |
247 // TODO(creis): Enable this on Android when we can kill the process there. | 293 // TODO(creis): Enable this on Android when we can kill the process there. |
248 #if defined(OS_ANDROID) | 294 #if defined(OS_ANDROID) |
249 #define MAYBE_CrashSubframe DISABLED_CrashSubframe | 295 #define MAYBE_CrashSubframe DISABLED_CrashSubframe |
250 #else | 296 #else |
251 #define MAYBE_CrashSubframe CrashSubframe | 297 #define MAYBE_CrashSubframe CrashSubframe |
252 #endif | 298 #endif |
253 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CrashSubframe) { | 299 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CrashSubframe) { |
254 host_resolver()->AddRule("*", "127.0.0.1"); | 300 host_resolver()->AddRule("*", "127.0.0.1"); |
255 ASSERT_TRUE(test_server()->Start()); | 301 ASSERT_TRUE(test_server()->Start()); |
256 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 302 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
257 NavigateToURL(shell(), main_url); | 303 NavigateToURL(shell(), main_url); |
258 | 304 |
259 StartFrameAtDataURL(); | 305 StartFrameAtDataURL(); |
260 | 306 |
261 // These must stay in scope with replace_host. | 307 // These must stay in scope with replace_host. |
262 GURL::Replacements replace_host; | 308 GURL::Replacements replace_host; |
263 std::string foo_com("foo.com"); | 309 std::string foo_com("foo.com"); |
264 | 310 |
265 // Load cross-site page into iframe. | 311 // Load cross-site page into iframe. |
266 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | 312 GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
267 replace_host.SetHostStr(foo_com); | 313 replace_host.SetHostStr(foo_com); |
268 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 314 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
269 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); | 315 EXPECT_TRUE(NavigateFrameToURLInRenderer(shell(), cross_site_url, "test")); |
270 | 316 |
271 // Check the subframe process. | 317 // Check the subframe process. |
272 FrameTreeNode* root = | 318 FrameTreeNode* root = |
273 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 319 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
274 GetFrameTree()->root(); | 320 GetFrameTree()->root(); |
275 ASSERT_EQ(1U, root->child_count()); | 321 ASSERT_EQ(1U, root->child_count()); |
276 FrameTreeNode* child = root->child_at(0); | 322 FrameTreeNode* child = root->child_at(0); |
277 EXPECT_EQ(main_url, root->current_url()); | 323 EXPECT_EQ(main_url, root->current_url()); |
278 EXPECT_EQ(cross_site_url, child->current_url()); | 324 EXPECT_EQ(cross_site_url, child->current_url()); |
279 | 325 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 GURL https_url(https_server.GetURL("files/title1.html")); | 369 GURL https_url(https_server.GetURL("files/title1.html")); |
324 | 370 |
325 NavigateToURL(shell(), main_url); | 371 NavigateToURL(shell(), main_url); |
326 | 372 |
327 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 373 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
328 { | 374 { |
329 // Load cross-site client-redirect page into Iframe. | 375 // Load cross-site client-redirect page into Iframe. |
330 // Should be blocked. | 376 // Should be blocked. |
331 GURL client_redirect_https_url(https_server.GetURL( | 377 GURL client_redirect_https_url(https_server.GetURL( |
332 "client-redirect?files/title1.html")); | 378 "client-redirect?files/title1.html")); |
333 EXPECT_TRUE(NavigateIframeToURL(shell(), | 379 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
334 client_redirect_https_url, "test")); | 380 shell(), client_redirect_https_url, "test")); |
335 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 381 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
336 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 382 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
337 EXPECT_FALSE(observer.navigation_succeeded()); | 383 EXPECT_FALSE(observer.navigation_succeeded()); |
338 } | 384 } |
339 | 385 |
340 { | 386 { |
341 // Load cross-site server-redirect page into Iframe, | 387 // Load cross-site server-redirect page into Iframe, |
342 // which redirects to same-site page. | 388 // which redirects to same-site page. |
343 GURL server_redirect_http_url(https_server.GetURL( | 389 GURL server_redirect_http_url(https_server.GetURL( |
344 "server-redirect?" + http_url.spec())); | 390 "server-redirect?" + http_url.spec())); |
345 EXPECT_TRUE(NavigateIframeToURL(shell(), | 391 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
346 server_redirect_http_url, "test")); | 392 shell(), server_redirect_http_url, "test")); |
347 EXPECT_EQ(observer.navigation_url(), http_url); | 393 EXPECT_EQ(observer.navigation_url(), http_url); |
348 EXPECT_TRUE(observer.navigation_succeeded()); | 394 EXPECT_TRUE(observer.navigation_succeeded()); |
349 } | 395 } |
350 | 396 |
351 { | 397 { |
352 // Load cross-site server-redirect page into Iframe, | 398 // Load cross-site server-redirect page into Iframe, |
353 // which redirects to cross-site page. | 399 // which redirects to cross-site page. |
354 GURL server_redirect_http_url(https_server.GetURL( | 400 GURL server_redirect_http_url(https_server.GetURL( |
355 "server-redirect?files/title1.html")); | 401 "server-redirect?files/title1.html")); |
356 EXPECT_TRUE(NavigateIframeToURL(shell(), | 402 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
357 server_redirect_http_url, "test")); | 403 shell(), server_redirect_http_url, "test")); |
358 // DidFailProvisionalLoad when navigating to https_url. | 404 // DidFailProvisionalLoad when navigating to https_url. |
359 EXPECT_EQ(observer.navigation_url(), https_url); | 405 EXPECT_EQ(observer.navigation_url(), https_url); |
360 EXPECT_FALSE(observer.navigation_succeeded()); | 406 EXPECT_FALSE(observer.navigation_succeeded()); |
361 } | 407 } |
362 | 408 |
363 { | 409 { |
364 // Load same-site server-redirect page into Iframe, | 410 // Load same-site server-redirect page into Iframe, |
365 // which redirects to cross-site page. | 411 // which redirects to cross-site page. |
366 GURL server_redirect_http_url(test_server()->GetURL( | 412 GURL server_redirect_http_url(test_server()->GetURL( |
367 "server-redirect?" + https_url.spec())); | 413 "server-redirect?" + https_url.spec())); |
368 EXPECT_TRUE(NavigateIframeToURL(shell(), | 414 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
369 server_redirect_http_url, "test")); | 415 shell(), server_redirect_http_url, "test")); |
370 | 416 |
371 EXPECT_EQ(observer.navigation_url(), https_url); | 417 EXPECT_EQ(observer.navigation_url(), https_url); |
372 EXPECT_FALSE(observer.navigation_succeeded()); | 418 EXPECT_FALSE(observer.navigation_succeeded()); |
373 } | 419 } |
374 | 420 |
375 { | 421 { |
376 // Load same-site client-redirect page into Iframe, | 422 // Load same-site client-redirect page into Iframe, |
377 // which redirects to cross-site page. | 423 // which redirects to cross-site page. |
378 GURL client_redirect_http_url(test_server()->GetURL( | 424 GURL client_redirect_http_url(test_server()->GetURL( |
379 "client-redirect?" + https_url.spec())); | 425 "client-redirect?" + https_url.spec())); |
380 | 426 |
381 RedirectNotificationObserver load_observer2( | 427 RedirectNotificationObserver load_observer2( |
382 NOTIFICATION_LOAD_STOP, | 428 NOTIFICATION_LOAD_STOP, |
383 Source<NavigationController>( | 429 Source<NavigationController>( |
384 &shell()->web_contents()->GetController())); | 430 &shell()->web_contents()->GetController())); |
385 | 431 |
386 EXPECT_TRUE(NavigateIframeToURL(shell(), | 432 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
387 client_redirect_http_url, "test")); | 433 shell(), client_redirect_http_url, "test")); |
388 | 434 |
389 // Same-site Client-Redirect Page should be loaded successfully. | 435 // Same-site Client-Redirect Page should be loaded successfully. |
390 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 436 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
391 EXPECT_TRUE(observer.navigation_succeeded()); | 437 EXPECT_TRUE(observer.navigation_succeeded()); |
392 | 438 |
393 // Redirecting to Cross-site Page should be blocked. | 439 // Redirecting to Cross-site Page should be blocked. |
394 load_observer2.Wait(); | 440 load_observer2.Wait(); |
395 EXPECT_EQ(observer.navigation_url(), https_url); | 441 EXPECT_EQ(observer.navigation_url(), https_url); |
396 EXPECT_FALSE(observer.navigation_succeeded()); | 442 EXPECT_FALSE(observer.navigation_succeeded()); |
397 } | 443 } |
398 | 444 |
399 { | 445 { |
400 // Load same-site server-redirect page into Iframe, | 446 // Load same-site server-redirect page into Iframe, |
401 // which redirects to same-site page. | 447 // which redirects to same-site page. |
402 GURL server_redirect_http_url(test_server()->GetURL( | 448 GURL server_redirect_http_url(test_server()->GetURL( |
403 "server-redirect?files/title1.html")); | 449 "server-redirect?files/title1.html")); |
404 EXPECT_TRUE(NavigateIframeToURL(shell(), | 450 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
405 server_redirect_http_url, "test")); | 451 shell(), server_redirect_http_url, "test")); |
406 EXPECT_EQ(observer.navigation_url(), http_url); | 452 EXPECT_EQ(observer.navigation_url(), http_url); |
407 EXPECT_TRUE(observer.navigation_succeeded()); | 453 EXPECT_TRUE(observer.navigation_succeeded()); |
408 } | 454 } |
409 | 455 |
410 { | 456 { |
411 // Load same-site client-redirect page into Iframe, | 457 // Load same-site client-redirect page into Iframe, |
412 // which redirects to same-site page. | 458 // which redirects to same-site page. |
413 GURL client_redirect_http_url(test_server()->GetURL( | 459 GURL client_redirect_http_url(test_server()->GetURL( |
414 "client-redirect?" + http_url.spec())); | 460 "client-redirect?" + http_url.spec())); |
415 RedirectNotificationObserver load_observer2( | 461 RedirectNotificationObserver load_observer2( |
416 NOTIFICATION_LOAD_STOP, | 462 NOTIFICATION_LOAD_STOP, |
417 Source<NavigationController>( | 463 Source<NavigationController>( |
418 &shell()->web_contents()->GetController())); | 464 &shell()->web_contents()->GetController())); |
419 | 465 |
420 EXPECT_TRUE(NavigateIframeToURL(shell(), | 466 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
421 client_redirect_http_url, "test")); | 467 shell(), client_redirect_http_url, "test")); |
422 | 468 |
423 // Same-site Client-Redirect Page should be loaded successfully. | 469 // Same-site Client-Redirect Page should be loaded successfully. |
424 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 470 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
425 EXPECT_TRUE(observer.navigation_succeeded()); | 471 EXPECT_TRUE(observer.navigation_succeeded()); |
426 | 472 |
427 // Redirecting to Same-site Page should be loaded successfully. | 473 // Redirecting to Same-site Page should be loaded successfully. |
428 load_observer2.Wait(); | 474 load_observer2.Wait(); |
429 EXPECT_EQ(observer.navigation_url(), http_url); | 475 EXPECT_EQ(observer.navigation_url(), http_url); |
430 EXPECT_TRUE(observer.navigation_succeeded()); | 476 EXPECT_TRUE(observer.navigation_succeeded()); |
431 } | 477 } |
(...skipping 26 matching lines...) Expand all Loading... | |
458 "client-redirect?" + http_url.spec())); | 504 "client-redirect?" + http_url.spec())); |
459 GURL client_redirect_http_url(test_server()->GetURL( | 505 GURL client_redirect_http_url(test_server()->GetURL( |
460 "client-redirect?" + client_redirect_https_url.spec())); | 506 "client-redirect?" + client_redirect_https_url.spec())); |
461 | 507 |
462 // We should wait until second client redirect get cancelled. | 508 // We should wait until second client redirect get cancelled. |
463 RedirectNotificationObserver load_observer2( | 509 RedirectNotificationObserver load_observer2( |
464 NOTIFICATION_LOAD_STOP, | 510 NOTIFICATION_LOAD_STOP, |
465 Source<NavigationController>( | 511 Source<NavigationController>( |
466 &shell()->web_contents()->GetController())); | 512 &shell()->web_contents()->GetController())); |
467 | 513 |
468 EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test")); | 514 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
515 shell(), client_redirect_http_url, "test")); | |
469 | 516 |
470 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 517 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
471 load_observer2.Wait(); | 518 load_observer2.Wait(); |
472 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 519 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
473 EXPECT_FALSE(observer.navigation_succeeded()); | 520 EXPECT_FALSE(observer.navigation_succeeded()); |
474 } | 521 } |
475 | 522 |
476 { | 523 { |
477 // Load server-redirect page pointing to a cross-site server-redirect page, | 524 // Load server-redirect page pointing to a cross-site server-redirect page, |
478 // which eventually redirect back to same-site page. | 525 // which eventually redirect back to same-site page. |
479 GURL server_redirect_https_url(https_server.GetURL( | 526 GURL server_redirect_https_url(https_server.GetURL( |
480 "server-redirect?" + http_url.spec())); | 527 "server-redirect?" + http_url.spec())); |
481 GURL server_redirect_http_url(test_server()->GetURL( | 528 GURL server_redirect_http_url(test_server()->GetURL( |
482 "server-redirect?" + server_redirect_https_url.spec())); | 529 "server-redirect?" + server_redirect_https_url.spec())); |
483 EXPECT_TRUE(NavigateIframeToURL(shell(), | 530 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
484 server_redirect_http_url, "test")); | 531 shell(), server_redirect_http_url, "test")); |
485 EXPECT_EQ(observer.navigation_url(), http_url); | 532 EXPECT_EQ(observer.navigation_url(), http_url); |
486 EXPECT_TRUE(observer.navigation_succeeded()); | 533 EXPECT_TRUE(observer.navigation_succeeded()); |
487 } | 534 } |
488 | 535 |
489 { | 536 { |
490 // Load server-redirect page pointing to a cross-site server-redirect page, | 537 // Load server-redirect page pointing to a cross-site server-redirect page, |
491 // which eventually redirects back to cross-site page. | 538 // which eventually redirects back to cross-site page. |
492 GURL server_redirect_https_url(https_server.GetURL( | 539 GURL server_redirect_https_url(https_server.GetURL( |
493 "server-redirect?" + https_url.spec())); | 540 "server-redirect?" + https_url.spec())); |
494 GURL server_redirect_http_url(test_server()->GetURL( | 541 GURL server_redirect_http_url(test_server()->GetURL( |
495 "server-redirect?" + server_redirect_https_url.spec())); | 542 "server-redirect?" + server_redirect_https_url.spec())); |
496 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 543 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
544 shell(), server_redirect_http_url, "test")); | |
497 | 545 |
498 // DidFailProvisionalLoad when navigating to https_url. | 546 // DidFailProvisionalLoad when navigating to https_url. |
499 EXPECT_EQ(observer.navigation_url(), https_url); | 547 EXPECT_EQ(observer.navigation_url(), https_url); |
500 EXPECT_FALSE(observer.navigation_succeeded()); | 548 EXPECT_FALSE(observer.navigation_succeeded()); |
501 } | 549 } |
502 | 550 |
503 { | 551 { |
504 // Load server-redirect page pointing to a cross-site client-redirect page, | 552 // Load server-redirect page pointing to a cross-site client-redirect page, |
505 // which eventually redirects back to same-site page. | 553 // which eventually redirects back to same-site page. |
506 GURL client_redirect_http_url(https_server.GetURL( | 554 GURL client_redirect_http_url(https_server.GetURL( |
507 "client-redirect?" + http_url.spec())); | 555 "client-redirect?" + http_url.spec())); |
508 GURL server_redirect_http_url(test_server()->GetURL( | 556 GURL server_redirect_http_url(test_server()->GetURL( |
509 "server-redirect?" + client_redirect_http_url.spec())); | 557 "server-redirect?" + client_redirect_http_url.spec())); |
510 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 558 EXPECT_TRUE(NavigateFrameToURLInRenderer( |
559 shell(), server_redirect_http_url, "test")); | |
511 | 560 |
512 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 561 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
513 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 562 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
514 EXPECT_FALSE(observer.navigation_succeeded()); | 563 EXPECT_FALSE(observer.navigation_succeeded()); |
515 } | 564 } |
516 } | 565 } |
517 | 566 |
518 } // namespace content | 567 } // namespace content |
OLD | NEW |