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 "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/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
11 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
12 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/frame_host/render_frame_proxy_host.h" | 13 #include "content/browser/frame_host/render_frame_proxy_host.h" |
14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/web_contents_observer.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/content_browser_test_utils.h" | 23 #include "content/public/test/content_browser_test_utils.h" |
23 #include "content/public/test/test_navigation_observer.h" | 24 #include "content/public/test/test_navigation_observer.h" |
24 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
25 #include "content/shell/browser/shell.h" | 26 #include "content/shell/browser/shell.h" |
26 #include "content/test/content_browser_test_utils_internal.h" | 27 #include "content/test/content_browser_test_utils_internal.h" |
27 #include "content/test/test_frame_navigation_observer.h" | 28 #include "content/test/test_frame_navigation_observer.h" |
28 #include "net/dns/mock_host_resolver.h" | 29 #include "net/dns/mock_host_resolver.h" |
29 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 | 33 |
| 34 class SitePerProcessWebContentsObserver: public WebContentsObserver { |
| 35 public: |
| 36 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) |
| 37 : WebContentsObserver(web_contents), |
| 38 navigation_succeeded_(false) {} |
| 39 ~SitePerProcessWebContentsObserver() override {} |
| 40 |
| 41 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host, |
| 42 const GURL& validated_url, |
| 43 bool is_error_page, |
| 44 bool is_iframe_srcdoc) override { |
| 45 navigation_succeeded_ = false; |
| 46 } |
| 47 |
| 48 void DidFailProvisionalLoad( |
| 49 RenderFrameHost* render_frame_host, |
| 50 const GURL& validated_url, |
| 51 int error_code, |
| 52 const base::string16& error_description) override { |
| 53 navigation_url_ = validated_url; |
| 54 navigation_succeeded_ = false; |
| 55 } |
| 56 |
| 57 void DidCommitProvisionalLoadForFrame( |
| 58 RenderFrameHost* render_frame_host, |
| 59 const GURL& url, |
| 60 ui::PageTransition transition_type) override { |
| 61 navigation_url_ = url; |
| 62 navigation_succeeded_ = true; |
| 63 } |
| 64 |
| 65 const GURL& navigation_url() const { |
| 66 return navigation_url_; |
| 67 } |
| 68 |
| 69 int navigation_succeeded() const { return navigation_succeeded_; } |
| 70 |
| 71 private: |
| 72 GURL navigation_url_; |
| 73 bool navigation_succeeded_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(SitePerProcessWebContentsObserver); |
| 76 }; |
| 77 |
33 class RedirectNotificationObserver : public NotificationObserver { | 78 class RedirectNotificationObserver : public NotificationObserver { |
34 public: | 79 public: |
35 // Register to listen for notifications of the given type from either a | 80 // Register to listen for notifications of the given type from either a |
36 // specific source, or from all sources if |source| is | 81 // specific source, or from all sources if |source| is |
37 // NotificationService::AllSources(). | 82 // NotificationService::AllSources(). |
38 RedirectNotificationObserver(int notification_type, | 83 RedirectNotificationObserver(int notification_type, |
39 const NotificationSource& source); | 84 const NotificationSource& source); |
40 ~RedirectNotificationObserver() override; | 85 ~RedirectNotificationObserver() override; |
41 | 86 |
42 // Wait until the specified notification occurs. If the notification was | 87 // Wait until the specified notification occurs. If the notification was |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // correct documents are committed. | 231 // correct documents are committed. |
187 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 232 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
188 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 233 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
189 NavigateToURL(shell(), main_url); | 234 NavigateToURL(shell(), main_url); |
190 | 235 |
191 // It is safe to obtain the root frame tree node here, as it doesn't change. | 236 // It is safe to obtain the root frame tree node here, as it doesn't change. |
192 FrameTreeNode* root = | 237 FrameTreeNode* root = |
193 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 238 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
194 GetFrameTree()->root(); | 239 GetFrameTree()->root(); |
195 | 240 |
196 TestNavigationObserver observer(shell()->web_contents()); | 241 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
197 | 242 |
198 // Load same-site page into iframe. | 243 // Load same-site page into iframe. |
199 FrameTreeNode* child = root->child_at(0); | 244 FrameTreeNode* child = root->child_at(0); |
200 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 245 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
201 NavigateFrameToURL(child, http_url); | 246 NavigateFrameToURL(child, http_url); |
202 EXPECT_EQ(http_url, observer.last_navigation_url()); | 247 EXPECT_EQ(http_url, observer.navigation_url()); |
203 EXPECT_TRUE(observer.last_navigation_succeeded()); | 248 EXPECT_TRUE(observer.navigation_succeeded()); |
204 { | 249 { |
205 // There should be only one RenderWidgetHost when there are no | 250 // There should be only one RenderWidgetHost when there are no |
206 // cross-process iframes. | 251 // cross-process iframes. |
207 std::set<RenderWidgetHostView*> views_set = | 252 std::set<RenderWidgetHostView*> views_set = |
208 static_cast<WebContentsImpl*>(shell()->web_contents()) | 253 static_cast<WebContentsImpl*>(shell()->web_contents()) |
209 ->GetRenderWidgetHostViewsInTree(); | 254 ->GetRenderWidgetHostViewsInTree(); |
210 EXPECT_EQ(1U, views_set.size()); | 255 EXPECT_EQ(1U, views_set.size()); |
211 } | 256 } |
212 RenderFrameProxyHost* proxy_to_parent = | 257 RenderFrameProxyHost* proxy_to_parent = |
213 child->render_manager()->GetRenderFrameProxyHost( | 258 child->render_manager()->GetRenderFrameProxyHost( |
214 shell()->web_contents()->GetSiteInstance()); | 259 shell()->web_contents()->GetSiteInstance()); |
215 EXPECT_FALSE(proxy_to_parent); | 260 EXPECT_FALSE(proxy_to_parent); |
216 | 261 |
217 // Load cross-site page into iframe. | 262 // Load cross-site page into iframe. |
218 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 263 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
219 NavigateFrameToURL(root->child_at(0), url); | 264 NavigateFrameToURL(root->child_at(0), url); |
220 // Verify that the navigation succeeded and the expected URL was loaded. | 265 // Verify that the navigation succeeded and the expected URL was loaded. |
221 EXPECT_TRUE(observer.last_navigation_succeeded()); | 266 EXPECT_TRUE(observer.navigation_succeeded()); |
222 EXPECT_EQ(url, observer.last_navigation_url()); | 267 EXPECT_EQ(url, observer.navigation_url()); |
223 | 268 |
224 // Ensure that we have created a new process for the subframe. | 269 // Ensure that we have created a new process for the subframe. |
225 ASSERT_EQ(2U, root->child_count()); | 270 ASSERT_EQ(2U, root->child_count()); |
226 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 271 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
227 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 272 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
228 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 273 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
229 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 274 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
230 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 275 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
231 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 276 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
232 { | 277 { |
(...skipping 10 matching lines...) Expand all Loading... |
243 // The out-of-process iframe should have its own RenderWidgetHost, | 288 // The out-of-process iframe should have its own RenderWidgetHost, |
244 // independent of any RenderViewHost. | 289 // independent of any RenderViewHost. |
245 EXPECT_NE( | 290 EXPECT_NE( |
246 rvh->GetView(), | 291 rvh->GetView(), |
247 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 292 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
248 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); | 293 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); |
249 | 294 |
250 // Load another cross-site page into the same iframe. | 295 // Load another cross-site page into the same iframe. |
251 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 296 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
252 NavigateFrameToURL(root->child_at(0), url); | 297 NavigateFrameToURL(root->child_at(0), url); |
253 EXPECT_TRUE(observer.last_navigation_succeeded()); | 298 EXPECT_TRUE(observer.navigation_succeeded()); |
254 EXPECT_EQ(url, observer.last_navigation_url()); | 299 EXPECT_EQ(url, observer.navigation_url()); |
255 | 300 |
256 // Check again that a new process is created and is different from the | 301 // Check again that a new process is created and is different from the |
257 // top level one and the previous one. | 302 // top level one and the previous one. |
258 ASSERT_EQ(2U, root->child_count()); | 303 ASSERT_EQ(2U, root->child_count()); |
259 child = root->child_at(0); | 304 child = root->child_at(0); |
260 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 305 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
261 child->current_frame_host()->render_view_host()); | 306 child->current_frame_host()->render_view_host()); |
262 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 307 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
263 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 308 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
264 child->current_frame_host()->GetSiteInstance()); | 309 child->current_frame_host()->GetSiteInstance()); |
(...skipping 20 matching lines...) Expand all Loading... |
285 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 330 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
286 DISABLED_NavigateRemoteFrame) { | 331 DISABLED_NavigateRemoteFrame) { |
287 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 332 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
288 NavigateToURL(shell(), main_url); | 333 NavigateToURL(shell(), main_url); |
289 | 334 |
290 // It is safe to obtain the root frame tree node here, as it doesn't change. | 335 // It is safe to obtain the root frame tree node here, as it doesn't change. |
291 FrameTreeNode* root = | 336 FrameTreeNode* root = |
292 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 337 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
293 GetFrameTree()->root(); | 338 GetFrameTree()->root(); |
294 | 339 |
295 TestNavigationObserver observer(shell()->web_contents()); | 340 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
296 | 341 |
297 // Load same-site page into iframe. | 342 // Load same-site page into iframe. |
298 FrameTreeNode* child = root->child_at(0); | 343 FrameTreeNode* child = root->child_at(0); |
299 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 344 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
300 NavigateFrameToURL(child, http_url); | 345 NavigateFrameToURL(child, http_url); |
301 EXPECT_EQ(http_url, observer.last_navigation_url()); | 346 EXPECT_EQ(http_url, observer.navigation_url()); |
302 EXPECT_TRUE(observer.last_navigation_succeeded()); | 347 EXPECT_TRUE(observer.navigation_succeeded()); |
303 | 348 |
304 // Load cross-site page into iframe. | 349 // Load cross-site page into iframe. |
305 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 350 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
306 NavigateFrameToURL(root->child_at(0), url); | 351 NavigateFrameToURL(root->child_at(0), url); |
307 EXPECT_TRUE(observer.last_navigation_succeeded()); | 352 EXPECT_TRUE(observer.navigation_succeeded()); |
308 EXPECT_EQ(url, observer.last_navigation_url()); | 353 EXPECT_EQ(url, observer.navigation_url()); |
309 | 354 |
310 // Ensure that we have created a new process for the subframe. | 355 // Ensure that we have created a new process for the subframe. |
311 ASSERT_EQ(2U, root->child_count()); | 356 ASSERT_EQ(2U, root->child_count()); |
312 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 357 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
313 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 358 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
314 | 359 |
315 // Emulate the main frame changing the src of the iframe such that it | 360 // Emulate the main frame changing the src of the iframe such that it |
316 // navigates cross-site. | 361 // navigates cross-site. |
317 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 362 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
318 NavigateIframeToURL(shell()->web_contents(), "test", url); | 363 NavigateIframeToURL(shell()->web_contents(), "test", url); |
319 EXPECT_TRUE(observer.last_navigation_succeeded()); | 364 EXPECT_TRUE(observer.navigation_succeeded()); |
320 EXPECT_EQ(url, observer.last_navigation_url()); | 365 EXPECT_EQ(url, observer.navigation_url()); |
321 | 366 |
322 // Check again that a new process is created and is different from the | 367 // Check again that a new process is created and is different from the |
323 // top level one and the previous one. | 368 // top level one and the previous one. |
324 ASSERT_EQ(2U, root->child_count()); | 369 ASSERT_EQ(2U, root->child_count()); |
325 child = root->child_at(0); | 370 child = root->child_at(0); |
326 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 371 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
327 child->current_frame_host()->GetSiteInstance()); | 372 child->current_frame_host()->GetSiteInstance()); |
328 EXPECT_NE(site_instance, | 373 EXPECT_NE(site_instance, |
329 child->current_frame_host()->GetSiteInstance()); | 374 child->current_frame_host()->GetSiteInstance()); |
330 | 375 |
331 // Navigate back to the parent's origin and ensure we return to the | 376 // Navigate back to the parent's origin and ensure we return to the |
332 // parent's process. | 377 // parent's process. |
333 NavigateFrameToURL(child, http_url); | 378 NavigateFrameToURL(child, http_url); |
334 EXPECT_EQ(http_url, observer.last_navigation_url()); | 379 EXPECT_EQ(http_url, observer.navigation_url()); |
335 EXPECT_TRUE(observer.last_navigation_succeeded()); | 380 EXPECT_TRUE(observer.navigation_succeeded()); |
336 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 381 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
337 child->current_frame_host()->GetSiteInstance()); | 382 child->current_frame_host()->GetSiteInstance()); |
338 } | 383 } |
339 | 384 |
340 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies | 385 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies |
341 // of C from the tree. | 386 // of C from the tree. |
342 // | 387 // |
343 // 1 A A | 388 // 1 A A |
344 // / \ / \ / \ . | 389 // / \ / \ / \ . |
345 // 2 3 -> B A -> Kill B -> B* A | 390 // 2 3 -> B A -> Kill B -> B* A |
346 // / / | 391 // / / |
347 // 4 C | 392 // 4 C |
348 // | 393 // |
349 // node1 is the root. | 394 // node1 is the root. |
350 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. | 395 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. |
351 // After we kill B, make sure proxies for C are cleared. | 396 // After we kill B, make sure proxies for C are cleared. |
352 // | 397 // |
353 // TODO(lazyboy): Once http://crbug.com/432107 is fixed, we should also make | 398 // TODO(lazyboy): Once http://crbug.com/432107 is fixed, we should also make |
354 // sure that proxies for B are not cleared when we kill B. | 399 // sure that proxies for B are not cleared when we kill B. |
355 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 400 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
356 KillingRendererClearsDescendantProxies) { | 401 KillingRendererClearsDescendantProxies) { |
357 GURL main_url( | 402 GURL main_url( |
358 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 403 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
359 NavigateToURL(shell(), main_url); | 404 NavigateToURL(shell(), main_url); |
360 | 405 |
361 // It is safe to obtain the root frame tree node here, as it doesn't change. | 406 // It is safe to obtain the root frame tree node here, as it doesn't change. |
362 FrameTreeNode* root = | 407 FrameTreeNode* root = |
363 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 408 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
364 GetFrameTree()->root(); | 409 GetFrameTree()->root(); |
365 TestNavigationObserver observer(shell()->web_contents()); | 410 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
366 | 411 |
367 ASSERT_EQ(2U, root->child_count()); | 412 ASSERT_EQ(2U, root->child_count()); |
368 | 413 |
369 // Navigate the second subframe (node3) to a local frame. | 414 // Navigate the second subframe (node3) to a local frame. |
370 GURL site_a_url(embedded_test_server()->GetURL("/title1.html")); | 415 GURL site_a_url(embedded_test_server()->GetURL("/title1.html")); |
371 NavigateFrameToURL(root->child_at(1), site_a_url); | 416 NavigateFrameToURL(root->child_at(1), site_a_url); |
372 | 417 |
373 // Navigate the first subframe (node2) to a cross-site page with two | 418 // Navigate the first subframe (node2) to a cross-site page with two |
374 // subframes. | 419 // subframes. |
375 // NavigateFrameToURL can't be used here because it doesn't guarantee that | 420 // NavigateFrameToURL can't be used here because it doesn't guarantee that |
(...skipping 18 matching lines...) Expand all Loading... |
394 // Ensure that a new process is *not* created for node3. | 439 // Ensure that a new process is *not* created for node3. |
395 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 440 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
396 root->child_at(1)->current_frame_host()->GetSiteInstance()); | 441 root->child_at(1)->current_frame_host()->GetSiteInstance()); |
397 | 442 |
398 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 443 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
399 | 444 |
400 // Navigate node4 to cross-site-page. | 445 // Navigate node4 to cross-site-page. |
401 FrameTreeNode* node4 = root->child_at(0)->child_at(0); | 446 FrameTreeNode* node4 = root->child_at(0)->child_at(0); |
402 GURL site_c_url(embedded_test_server()->GetURL("baz.com", "/title2.html")); | 447 GURL site_c_url(embedded_test_server()->GetURL("baz.com", "/title2.html")); |
403 NavigateFrameToURL(node4, site_c_url); | 448 NavigateFrameToURL(node4, site_c_url); |
404 EXPECT_TRUE(observer.last_navigation_succeeded()); | 449 EXPECT_TRUE(observer.navigation_succeeded()); |
405 EXPECT_EQ(site_c_url, observer.last_navigation_url()); | 450 EXPECT_EQ(site_c_url, observer.navigation_url()); |
406 | 451 |
407 // |site_instance_c| is expected to go away once we kill |child_process_b| | 452 // |site_instance_c| is expected to go away once we kill |child_process_b| |
408 // below, so create a local scope so we can extend the lifetime of | 453 // below, so create a local scope so we can extend the lifetime of |
409 // |site_instance_c| with a refptr. | 454 // |site_instance_c| with a refptr. |
410 { | 455 { |
411 SiteInstance* site_instance_b = | 456 SiteInstance* site_instance_b = |
412 root->child_at(0)->current_frame_host()->GetSiteInstance(); | 457 root->child_at(0)->current_frame_host()->GetSiteInstance(); |
413 scoped_refptr<SiteInstanceImpl> site_instance_c = | 458 scoped_refptr<SiteInstanceImpl> site_instance_c = |
414 node4->current_frame_host()->GetSiteInstance(); | 459 node4->current_frame_host()->GetSiteInstance(); |
415 | 460 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 net::SpawnedTestServer::kLocalhost, | 559 net::SpawnedTestServer::kLocalhost, |
515 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 560 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
516 ASSERT_TRUE(https_server.Start()); | 561 ASSERT_TRUE(https_server.Start()); |
517 | 562 |
518 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 563 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
519 GURL http_url(test_server()->GetURL("files/title1.html")); | 564 GURL http_url(test_server()->GetURL("files/title1.html")); |
520 GURL https_url(https_server.GetURL("files/title1.html")); | 565 GURL https_url(https_server.GetURL("files/title1.html")); |
521 | 566 |
522 NavigateToURL(shell(), main_url); | 567 NavigateToURL(shell(), main_url); |
523 | 568 |
524 TestNavigationObserver observer(shell()->web_contents()); | 569 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
525 { | 570 { |
526 // Load cross-site client-redirect page into Iframe. | 571 // Load cross-site client-redirect page into Iframe. |
527 // Should be blocked. | 572 // Should be blocked. |
528 GURL client_redirect_https_url(https_server.GetURL( | 573 GURL client_redirect_https_url(https_server.GetURL( |
529 "client-redirect?files/title1.html")); | 574 "client-redirect?files/title1.html")); |
530 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 575 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
531 client_redirect_https_url)); | 576 client_redirect_https_url)); |
532 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 577 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
533 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); | 578 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
534 EXPECT_FALSE(observer.last_navigation_succeeded()); | 579 EXPECT_FALSE(observer.navigation_succeeded()); |
535 } | 580 } |
536 | 581 |
537 { | 582 { |
538 // Load cross-site server-redirect page into Iframe, | 583 // Load cross-site server-redirect page into Iframe, |
539 // which redirects to same-site page. | 584 // which redirects to same-site page. |
540 GURL server_redirect_http_url(https_server.GetURL( | 585 GURL server_redirect_http_url(https_server.GetURL( |
541 "server-redirect?" + http_url.spec())); | 586 "server-redirect?" + http_url.spec())); |
542 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 587 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
543 server_redirect_http_url)); | 588 server_redirect_http_url)); |
544 EXPECT_EQ(observer.last_navigation_url(), http_url); | 589 EXPECT_EQ(observer.navigation_url(), http_url); |
545 EXPECT_TRUE(observer.last_navigation_succeeded()); | 590 EXPECT_TRUE(observer.navigation_succeeded()); |
546 } | 591 } |
547 | 592 |
548 { | 593 { |
549 // Load cross-site server-redirect page into Iframe, | 594 // Load cross-site server-redirect page into Iframe, |
550 // which redirects to cross-site page. | 595 // which redirects to cross-site page. |
551 GURL server_redirect_http_url(https_server.GetURL( | 596 GURL server_redirect_http_url(https_server.GetURL( |
552 "server-redirect?files/title1.html")); | 597 "server-redirect?files/title1.html")); |
553 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 598 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
554 server_redirect_http_url)); | 599 server_redirect_http_url)); |
555 // DidFailProvisionalLoad when navigating to https_url. | 600 // DidFailProvisionalLoad when navigating to https_url. |
556 EXPECT_EQ(observer.last_navigation_url(), https_url); | 601 EXPECT_EQ(observer.navigation_url(), https_url); |
557 EXPECT_FALSE(observer.last_navigation_succeeded()); | 602 EXPECT_FALSE(observer.navigation_succeeded()); |
558 } | 603 } |
559 | 604 |
560 { | 605 { |
561 // Load same-site server-redirect page into Iframe, | 606 // Load same-site server-redirect page into Iframe, |
562 // which redirects to cross-site page. | 607 // which redirects to cross-site page. |
563 GURL server_redirect_http_url(test_server()->GetURL( | 608 GURL server_redirect_http_url(test_server()->GetURL( |
564 "server-redirect?" + https_url.spec())); | 609 "server-redirect?" + https_url.spec())); |
565 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 610 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
566 server_redirect_http_url)); | 611 server_redirect_http_url)); |
567 | 612 |
568 EXPECT_EQ(observer.last_navigation_url(), https_url); | 613 EXPECT_EQ(observer.navigation_url(), https_url); |
569 EXPECT_FALSE(observer.last_navigation_succeeded()); | 614 EXPECT_FALSE(observer.navigation_succeeded()); |
570 } | 615 } |
571 | 616 |
572 { | 617 { |
573 // Load same-site client-redirect page into Iframe, | 618 // Load same-site client-redirect page into Iframe, |
574 // which redirects to cross-site page. | 619 // which redirects to cross-site page. |
575 GURL client_redirect_http_url(test_server()->GetURL( | 620 GURL client_redirect_http_url(test_server()->GetURL( |
576 "client-redirect?" + https_url.spec())); | 621 "client-redirect?" + https_url.spec())); |
577 | 622 |
578 RedirectNotificationObserver load_observer2( | 623 RedirectNotificationObserver load_observer2( |
579 NOTIFICATION_LOAD_STOP, | 624 NOTIFICATION_LOAD_STOP, |
580 Source<NavigationController>( | 625 Source<NavigationController>( |
581 &shell()->web_contents()->GetController())); | 626 &shell()->web_contents()->GetController())); |
582 | 627 |
583 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 628 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
584 client_redirect_http_url)); | 629 client_redirect_http_url)); |
585 | 630 |
586 // Same-site Client-Redirect Page should be loaded successfully. | 631 // Same-site Client-Redirect Page should be loaded successfully. |
587 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); | 632 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
588 EXPECT_TRUE(observer.last_navigation_succeeded()); | 633 EXPECT_TRUE(observer.navigation_succeeded()); |
589 | 634 |
590 // Redirecting to Cross-site Page should be blocked. | 635 // Redirecting to Cross-site Page should be blocked. |
591 load_observer2.Wait(); | 636 load_observer2.Wait(); |
592 EXPECT_EQ(observer.last_navigation_url(), https_url); | 637 EXPECT_EQ(observer.navigation_url(), https_url); |
593 EXPECT_FALSE(observer.last_navigation_succeeded()); | 638 EXPECT_FALSE(observer.navigation_succeeded()); |
594 } | 639 } |
595 | 640 |
596 { | 641 { |
597 // Load same-site server-redirect page into Iframe, | 642 // Load same-site server-redirect page into Iframe, |
598 // which redirects to same-site page. | 643 // which redirects to same-site page. |
599 GURL server_redirect_http_url(test_server()->GetURL( | 644 GURL server_redirect_http_url(test_server()->GetURL( |
600 "server-redirect?files/title1.html")); | 645 "server-redirect?files/title1.html")); |
601 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 646 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
602 server_redirect_http_url)); | 647 server_redirect_http_url)); |
603 EXPECT_EQ(observer.last_navigation_url(), http_url); | 648 EXPECT_EQ(observer.navigation_url(), http_url); |
604 EXPECT_TRUE(observer.last_navigation_succeeded()); | 649 EXPECT_TRUE(observer.navigation_succeeded()); |
605 } | 650 } |
606 | 651 |
607 { | 652 { |
608 // Load same-site client-redirect page into Iframe, | 653 // Load same-site client-redirect page into Iframe, |
609 // which redirects to same-site page. | 654 // which redirects to same-site page. |
610 GURL client_redirect_http_url(test_server()->GetURL( | 655 GURL client_redirect_http_url(test_server()->GetURL( |
611 "client-redirect?" + http_url.spec())); | 656 "client-redirect?" + http_url.spec())); |
612 RedirectNotificationObserver load_observer2( | 657 RedirectNotificationObserver load_observer2( |
613 NOTIFICATION_LOAD_STOP, | 658 NOTIFICATION_LOAD_STOP, |
614 Source<NavigationController>( | 659 Source<NavigationController>( |
615 &shell()->web_contents()->GetController())); | 660 &shell()->web_contents()->GetController())); |
616 | 661 |
617 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 662 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
618 client_redirect_http_url)); | 663 client_redirect_http_url)); |
619 | 664 |
620 // Same-site Client-Redirect Page should be loaded successfully. | 665 // Same-site Client-Redirect Page should be loaded successfully. |
621 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); | 666 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
622 EXPECT_TRUE(observer.last_navigation_succeeded()); | 667 EXPECT_TRUE(observer.navigation_succeeded()); |
623 | 668 |
624 // Redirecting to Same-site Page should be loaded successfully. | 669 // Redirecting to Same-site Page should be loaded successfully. |
625 load_observer2.Wait(); | 670 load_observer2.Wait(); |
626 EXPECT_EQ(observer.last_navigation_url(), http_url); | 671 EXPECT_EQ(observer.navigation_url(), http_url); |
627 EXPECT_TRUE(observer.last_navigation_succeeded()); | 672 EXPECT_TRUE(observer.navigation_succeeded()); |
628 } | 673 } |
629 } | 674 } |
630 | 675 |
631 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 676 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
632 // security checks are back in place. | 677 // security checks are back in place. |
633 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 678 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
634 // on Android (http://crbug.com/187570). | 679 // on Android (http://crbug.com/187570). |
635 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 680 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
636 DISABLED_CrossSiteIframeRedirectTwice) { | 681 DISABLED_CrossSiteIframeRedirectTwice) { |
637 ASSERT_TRUE(test_server()->Start()); | 682 ASSERT_TRUE(test_server()->Start()); |
638 net::SpawnedTestServer https_server( | 683 net::SpawnedTestServer https_server( |
639 net::SpawnedTestServer::TYPE_HTTPS, | 684 net::SpawnedTestServer::TYPE_HTTPS, |
640 net::SpawnedTestServer::kLocalhost, | 685 net::SpawnedTestServer::kLocalhost, |
641 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 686 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
642 ASSERT_TRUE(https_server.Start()); | 687 ASSERT_TRUE(https_server.Start()); |
643 | 688 |
644 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 689 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
645 GURL http_url(test_server()->GetURL("files/title1.html")); | 690 GURL http_url(test_server()->GetURL("files/title1.html")); |
646 GURL https_url(https_server.GetURL("files/title1.html")); | 691 GURL https_url(https_server.GetURL("files/title1.html")); |
647 | 692 |
648 NavigateToURL(shell(), main_url); | 693 NavigateToURL(shell(), main_url); |
649 | 694 |
650 TestNavigationObserver observer(shell()->web_contents()); | 695 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
651 { | 696 { |
652 // Load client-redirect page pointing to a cross-site client-redirect page, | 697 // Load client-redirect page pointing to a cross-site client-redirect page, |
653 // which eventually redirects back to same-site page. | 698 // which eventually redirects back to same-site page. |
654 GURL client_redirect_https_url(https_server.GetURL( | 699 GURL client_redirect_https_url(https_server.GetURL( |
655 "client-redirect?" + http_url.spec())); | 700 "client-redirect?" + http_url.spec())); |
656 GURL client_redirect_http_url(test_server()->GetURL( | 701 GURL client_redirect_http_url(test_server()->GetURL( |
657 "client-redirect?" + client_redirect_https_url.spec())); | 702 "client-redirect?" + client_redirect_https_url.spec())); |
658 | 703 |
659 // We should wait until second client redirect get cancelled. | 704 // We should wait until second client redirect get cancelled. |
660 RedirectNotificationObserver load_observer2( | 705 RedirectNotificationObserver load_observer2( |
661 NOTIFICATION_LOAD_STOP, | 706 NOTIFICATION_LOAD_STOP, |
662 Source<NavigationController>( | 707 Source<NavigationController>( |
663 &shell()->web_contents()->GetController())); | 708 &shell()->web_contents()->GetController())); |
664 | 709 |
665 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 710 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
666 client_redirect_http_url)); | 711 client_redirect_http_url)); |
667 | 712 |
668 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 713 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
669 load_observer2.Wait(); | 714 load_observer2.Wait(); |
670 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); | 715 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
671 EXPECT_FALSE(observer.last_navigation_succeeded()); | 716 EXPECT_FALSE(observer.navigation_succeeded()); |
672 } | 717 } |
673 | 718 |
674 { | 719 { |
675 // Load server-redirect page pointing to a cross-site server-redirect page, | 720 // Load server-redirect page pointing to a cross-site server-redirect page, |
676 // which eventually redirect back to same-site page. | 721 // which eventually redirect back to same-site page. |
677 GURL server_redirect_https_url(https_server.GetURL( | 722 GURL server_redirect_https_url(https_server.GetURL( |
678 "server-redirect?" + http_url.spec())); | 723 "server-redirect?" + http_url.spec())); |
679 GURL server_redirect_http_url(test_server()->GetURL( | 724 GURL server_redirect_http_url(test_server()->GetURL( |
680 "server-redirect?" + server_redirect_https_url.spec())); | 725 "server-redirect?" + server_redirect_https_url.spec())); |
681 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 726 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
682 server_redirect_http_url)); | 727 server_redirect_http_url)); |
683 EXPECT_EQ(observer.last_navigation_url(), http_url); | 728 EXPECT_EQ(observer.navigation_url(), http_url); |
684 EXPECT_TRUE(observer.last_navigation_succeeded()); | 729 EXPECT_TRUE(observer.navigation_succeeded()); |
685 } | 730 } |
686 | 731 |
687 { | 732 { |
688 // Load server-redirect page pointing to a cross-site server-redirect page, | 733 // Load server-redirect page pointing to a cross-site server-redirect page, |
689 // which eventually redirects back to cross-site page. | 734 // which eventually redirects back to cross-site page. |
690 GURL server_redirect_https_url(https_server.GetURL( | 735 GURL server_redirect_https_url(https_server.GetURL( |
691 "server-redirect?" + https_url.spec())); | 736 "server-redirect?" + https_url.spec())); |
692 GURL server_redirect_http_url(test_server()->GetURL( | 737 GURL server_redirect_http_url(test_server()->GetURL( |
693 "server-redirect?" + server_redirect_https_url.spec())); | 738 "server-redirect?" + server_redirect_https_url.spec())); |
694 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 739 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
695 server_redirect_http_url)); | 740 server_redirect_http_url)); |
696 | 741 |
697 // DidFailProvisionalLoad when navigating to https_url. | 742 // DidFailProvisionalLoad when navigating to https_url. |
698 EXPECT_EQ(observer.last_navigation_url(), https_url); | 743 EXPECT_EQ(observer.navigation_url(), https_url); |
699 EXPECT_FALSE(observer.last_navigation_succeeded()); | 744 EXPECT_FALSE(observer.navigation_succeeded()); |
700 } | 745 } |
701 | 746 |
702 { | 747 { |
703 // Load server-redirect page pointing to a cross-site client-redirect page, | 748 // Load server-redirect page pointing to a cross-site client-redirect page, |
704 // which eventually redirects back to same-site page. | 749 // which eventually redirects back to same-site page. |
705 GURL client_redirect_http_url(https_server.GetURL( | 750 GURL client_redirect_http_url(https_server.GetURL( |
706 "client-redirect?" + http_url.spec())); | 751 "client-redirect?" + http_url.spec())); |
707 GURL server_redirect_http_url(test_server()->GetURL( | 752 GURL server_redirect_http_url(test_server()->GetURL( |
708 "server-redirect?" + client_redirect_http_url.spec())); | 753 "server-redirect?" + client_redirect_http_url.spec())); |
709 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 754 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
710 server_redirect_http_url)); | 755 server_redirect_http_url)); |
711 | 756 |
712 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 757 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
713 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); | 758 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
714 EXPECT_FALSE(observer.last_navigation_succeeded()); | 759 EXPECT_FALSE(observer.navigation_succeeded()); |
715 } | 760 } |
716 } | 761 } |
717 | 762 |
718 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are | 763 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are |
719 // created in the FrameTree skipping the subtree of the navigating frame. | 764 // created in the FrameTree skipping the subtree of the navigating frame. |
720 // | 765 // |
721 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 | 766 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 |
722 // Disabled on Windows due to flakiness on Win 7 bot. http://crbug.com/444563 | 767 // Disabled on Windows due to flakiness on Win 7 bot. http://crbug.com/444563 |
723 #if defined(OS_MACOSX) || defined(OS_WIN) | 768 #if defined(OS_MACOSX) || defined(OS_WIN) |
724 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree | 769 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree |
725 #else | 770 #else |
726 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree | 771 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree |
727 #endif | 772 #endif |
728 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 773 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
729 MAYBE_ProxyCreationSkipsSubtree) { | 774 MAYBE_ProxyCreationSkipsSubtree) { |
730 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 775 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
731 NavigateToURL(shell(), main_url); | 776 NavigateToURL(shell(), main_url); |
732 | 777 |
733 // It is safe to obtain the root frame tree node here, as it doesn't change. | 778 // It is safe to obtain the root frame tree node here, as it doesn't change. |
734 FrameTreeNode* root = | 779 FrameTreeNode* root = |
735 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 780 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
736 GetFrameTree()->root(); | 781 GetFrameTree()->root(); |
737 | 782 |
738 EXPECT_TRUE(root->child_at(1) != NULL); | 783 EXPECT_TRUE(root->child_at(1) != NULL); |
739 EXPECT_EQ(2U, root->child_at(1)->child_count()); | 784 EXPECT_EQ(2U, root->child_at(1)->child_count()); |
740 | 785 |
741 { | 786 { |
742 // Load same-site page into iframe. | 787 // Load same-site page into iframe. |
743 TestNavigationObserver observer(shell()->web_contents()); | 788 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
744 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 789 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
745 NavigateFrameToURL(root->child_at(0), http_url); | 790 NavigateFrameToURL(root->child_at(0), http_url); |
746 EXPECT_EQ(http_url, observer.last_navigation_url()); | 791 EXPECT_EQ(http_url, observer.navigation_url()); |
747 EXPECT_TRUE(observer.last_navigation_succeeded()); | 792 EXPECT_TRUE(observer.navigation_succeeded()); |
748 RenderFrameProxyHost* proxy_to_parent = | 793 RenderFrameProxyHost* proxy_to_parent = |
749 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( | 794 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( |
750 shell()->web_contents()->GetSiteInstance()); | 795 shell()->web_contents()->GetSiteInstance()); |
751 EXPECT_FALSE(proxy_to_parent); | 796 EXPECT_FALSE(proxy_to_parent); |
752 } | 797 } |
753 | 798 |
754 // Create the cross-site URL to navigate to. | 799 // Create the cross-site URL to navigate to. |
755 GURL cross_site_url = | 800 GURL cross_site_url = |
756 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); | 801 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); |
757 | 802 |
758 // Load cross-site page into the second iframe without waiting for the | 803 // Load cross-site page into the second iframe without waiting for the |
759 // navigation to complete. Once LoadURLWithParams returns, we would expect | 804 // navigation to complete. Once LoadURLWithParams returns, we would expect |
760 // proxies to have been created in the frame tree, but children of the | 805 // proxies to have been created in the frame tree, but children of the |
761 // navigating frame to still be present. The reason is that we don't run the | 806 // navigating frame to still be present. The reason is that we don't run the |
762 // message loop, so no IPCs that alter the frame tree can be processed. | 807 // message loop, so no IPCs that alter the frame tree can be processed. |
763 FrameTreeNode* child = root->child_at(1); | 808 FrameTreeNode* child = root->child_at(1); |
764 SiteInstance* site = NULL; | 809 SiteInstance* site = NULL; |
765 { | 810 { |
766 TestNavigationObserver observer(shell()->web_contents()); | 811 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
767 TestFrameNavigationObserver navigation_observer(child); | 812 TestFrameNavigationObserver navigation_observer(child); |
768 NavigationController::LoadURLParams params(cross_site_url); | 813 NavigationController::LoadURLParams params(cross_site_url); |
769 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 814 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
770 params.frame_tree_node_id = child->frame_tree_node_id(); | 815 params.frame_tree_node_id = child->frame_tree_node_id(); |
771 child->navigator()->GetController()->LoadURLWithParams(params); | 816 child->navigator()->GetController()->LoadURLWithParams(params); |
772 EXPECT_TRUE(child->render_manager()->pending_frame_host()); | 817 EXPECT_TRUE(child->render_manager()->pending_frame_host()); |
773 | 818 |
774 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); | 819 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); |
775 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); | 820 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); |
776 | 821 |
777 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); | 822 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); |
778 EXPECT_TRUE( | 823 EXPECT_TRUE( |
779 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); | 824 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); |
780 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); | 825 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); |
781 for (size_t i = 0; i < child->child_count(); ++i) { | 826 for (size_t i = 0; i < child->child_count(); ++i) { |
782 EXPECT_FALSE( | 827 EXPECT_FALSE( |
783 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); | 828 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); |
784 } | 829 } |
785 // Now that the verification is done, run the message loop and wait for the | 830 // Now that the verification is done, run the message loop and wait for the |
786 // navigation to complete. | 831 // navigation to complete. |
787 navigation_observer.Wait(); | 832 navigation_observer.Wait(); |
788 EXPECT_FALSE(child->render_manager()->pending_frame_host()); | 833 EXPECT_FALSE(child->render_manager()->pending_frame_host()); |
789 EXPECT_TRUE(observer.last_navigation_succeeded()); | 834 EXPECT_TRUE(observer.navigation_succeeded()); |
790 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); | 835 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
791 } | 836 } |
792 | 837 |
793 // Load another cross-site page into the same iframe. | 838 // Load another cross-site page into the same iframe. |
794 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); | 839 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); |
795 { | 840 { |
796 // Perform the same checks as the first cross-site navigation, since | 841 // Perform the same checks as the first cross-site navigation, since |
797 // there have been issues in subsequent cross-site navigations. Also ensure | 842 // there have been issues in subsequent cross-site navigations. Also ensure |
798 // that the SiteInstance has properly changed. | 843 // that the SiteInstance has properly changed. |
799 // TODO(nasko): Once we have proper cleanup of resources, add code to | 844 // TODO(nasko): Once we have proper cleanup of resources, add code to |
800 // verify that the intermediate SiteInstance/RenderFrameHost have been | 845 // verify that the intermediate SiteInstance/RenderFrameHost have been |
801 // properly cleaned up. | 846 // properly cleaned up. |
802 TestNavigationObserver observer(shell()->web_contents()); | 847 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
803 TestFrameNavigationObserver navigation_observer(child); | 848 TestFrameNavigationObserver navigation_observer(child); |
804 NavigationController::LoadURLParams params(cross_site_url); | 849 NavigationController::LoadURLParams params(cross_site_url); |
805 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 850 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
806 params.frame_tree_node_id = child->frame_tree_node_id(); | 851 params.frame_tree_node_id = child->frame_tree_node_id(); |
807 child->navigator()->GetController()->LoadURLWithParams(params); | 852 child->navigator()->GetController()->LoadURLWithParams(params); |
808 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); | 853 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); |
809 | 854 |
810 SiteInstance* site2 = | 855 SiteInstance* site2 = |
811 child->render_manager()->pending_frame_host()->GetSiteInstance(); | 856 child->render_manager()->pending_frame_host()->GetSiteInstance(); |
812 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); | 857 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); |
813 EXPECT_NE(site, site2); | 858 EXPECT_NE(site, site2); |
814 | 859 |
815 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); | 860 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); |
816 EXPECT_TRUE( | 861 EXPECT_TRUE( |
817 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); | 862 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); |
818 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); | 863 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); |
819 for (size_t i = 0; i < child->child_count(); ++i) { | 864 for (size_t i = 0; i < child->child_count(); ++i) { |
820 EXPECT_FALSE( | 865 EXPECT_FALSE( |
821 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); | 866 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); |
822 } | 867 } |
823 | 868 |
824 navigation_observer.Wait(); | 869 navigation_observer.Wait(); |
825 EXPECT_TRUE(observer.last_navigation_succeeded()); | 870 EXPECT_TRUE(observer.navigation_succeeded()); |
826 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); | 871 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
827 EXPECT_EQ(0U, child->child_count()); | 872 EXPECT_EQ(0U, child->child_count()); |
828 } | 873 } |
829 } | 874 } |
830 | 875 |
831 // Verify that origin replication works for an A-embed-B-embed-C hierarchy. | 876 // Verify that origin replication works for an A-embed-B-embed-C hierarchy. |
832 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { | 877 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
833 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 878 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
834 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 879 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
835 | 880 |
836 // It is safe to obtain the root frame tree node here, as it doesn't change. | 881 // It is safe to obtain the root frame tree node here, as it doesn't change. |
837 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 882 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
838 ->GetFrameTree() | 883 ->GetFrameTree() |
839 ->root(); | 884 ->root(); |
840 | 885 |
841 TestNavigationObserver observer(shell()->web_contents()); | 886 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
842 | 887 |
843 // Navigate the first subframe to a cross-site page with two subframes. | 888 // Navigate the first subframe to a cross-site page with two subframes. |
844 // NavigateFrameToURL can't be used here because it doesn't guarantee that | 889 // NavigateFrameToURL can't be used here because it doesn't guarantee that |
845 // FrameTreeNodes will have been created for child frames when it returns. | 890 // FrameTreeNodes will have been created for child frames when it returns. |
846 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); | 891 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); |
847 GURL foo_url( | 892 GURL foo_url( |
848 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); | 893 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); |
849 NavigationController::LoadURLParams params(foo_url); | 894 NavigationController::LoadURLParams params(foo_url); |
850 params.transition_type = ui::PAGE_TRANSITION_LINK; | 895 params.transition_type = ui::PAGE_TRANSITION_LINK; |
851 params.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); | 896 params.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); |
852 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params); | 897 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params); |
853 frame_observer.Wait(); | 898 frame_observer.Wait(); |
854 | 899 |
855 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, | 900 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, |
856 // since the frame has children that may have clobbered it in the observer. | 901 // since the frame has children that may have clobbered it in the observer. |
857 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); | 902 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); |
858 | 903 |
859 // Ensure that a new process is created for the subframe. | 904 // Ensure that a new process is created for the subframe. |
860 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 905 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
861 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 906 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
862 | 907 |
863 // Load cross-site page into subframe's subframe. | 908 // Load cross-site page into subframe's subframe. |
864 ASSERT_EQ(2U, root->child_at(0)->child_count()); | 909 ASSERT_EQ(2U, root->child_at(0)->child_count()); |
865 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); | 910 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); |
866 NavigateFrameToURL(root->child_at(0)->child_at(0), bar_url); | 911 NavigateFrameToURL(root->child_at(0)->child_at(0), bar_url); |
867 EXPECT_TRUE(observer.last_navigation_succeeded()); | 912 EXPECT_TRUE(observer.navigation_succeeded()); |
868 EXPECT_EQ(bar_url, observer.last_navigation_url()); | 913 EXPECT_EQ(bar_url, observer.navigation_url()); |
869 | 914 |
870 // Check that a new process is created and is different from the top one and | 915 // Check that a new process is created and is different from the top one and |
871 // the middle one. | 916 // the middle one. |
872 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); | 917 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); |
873 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 918 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
874 bottom_child->current_frame_host()->GetSiteInstance()); | 919 bottom_child->current_frame_host()->GetSiteInstance()); |
875 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), | 920 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), |
876 bottom_child->current_frame_host()->GetSiteInstance()); | 921 bottom_child->current_frame_host()->GetSiteInstance()); |
877 | 922 |
878 // Check that foo.com frame's location.ancestorOrigins contains the correct | 923 // Check that foo.com frame's location.ancestorOrigins contains the correct |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 // Verify that a child frame can retrieve the name property set by its parent. | 962 // Verify that a child frame can retrieve the name property set by its parent. |
918 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { | 963 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { |
919 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); | 964 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); |
920 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 965 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
921 | 966 |
922 // It is safe to obtain the root frame tree node here, as it doesn't change. | 967 // It is safe to obtain the root frame tree node here, as it doesn't change. |
923 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 968 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
924 ->GetFrameTree() | 969 ->GetFrameTree() |
925 ->root(); | 970 ->root(); |
926 | 971 |
927 TestNavigationObserver observer(shell()->web_contents()); | 972 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
928 | 973 |
929 // Load cross-site page into iframe. | 974 // Load cross-site page into iframe. |
930 GURL frame_url = | 975 GURL frame_url = |
931 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); | 976 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); |
932 NavigateFrameToURL(root->child_at(0), frame_url); | 977 NavigateFrameToURL(root->child_at(0), frame_url); |
933 EXPECT_TRUE(observer.last_navigation_succeeded()); | 978 EXPECT_TRUE(observer.navigation_succeeded()); |
934 EXPECT_EQ(frame_url, observer.last_navigation_url()); | 979 EXPECT_EQ(frame_url, observer.navigation_url()); |
935 | 980 |
936 // Ensure that a new process is created for the subframe. | 981 // Ensure that a new process is created for the subframe. |
937 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 982 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
938 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 983 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
939 | 984 |
940 // Check that the window.name seen by the frame matches the name attribute | 985 // Check that the window.name seen by the frame matches the name attribute |
941 // specified by its parent in the iframe tag. | 986 // specified by its parent in the iframe tag. |
942 std::string result; | 987 std::string result; |
943 EXPECT_TRUE(ExecuteScriptAndExtractString( | 988 EXPECT_TRUE(ExecuteScriptAndExtractString( |
944 root->child_at(0)->current_frame_host(), | 989 root->child_at(0)->current_frame_host(), |
(...skipping 11 matching lines...) Expand all Loading... |
956 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1001 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
957 DISABLED_NavigateRemoteToDataURL) { | 1002 DISABLED_NavigateRemoteToDataURL) { |
958 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 1003 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
959 NavigateToURL(shell(), main_url); | 1004 NavigateToURL(shell(), main_url); |
960 | 1005 |
961 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1006 // It is safe to obtain the root frame tree node here, as it doesn't change. |
962 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1007 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
963 ->GetFrameTree() | 1008 ->GetFrameTree() |
964 ->root(); | 1009 ->root(); |
965 | 1010 |
966 TestNavigationObserver observer(shell()->web_contents()); | 1011 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
967 | 1012 |
968 // Load cross-site page into iframe. | 1013 // Load cross-site page into iframe. |
969 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); | 1014 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
970 NavigateFrameToURL(root->child_at(0), url); | 1015 NavigateFrameToURL(root->child_at(0), url); |
971 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1016 EXPECT_TRUE(observer.navigation_succeeded()); |
972 EXPECT_EQ(url, observer.last_navigation_url()); | 1017 EXPECT_EQ(url, observer.navigation_url()); |
973 | 1018 |
974 // Ensure that we have created a new process for the subframe. | 1019 // Ensure that we have created a new process for the subframe. |
975 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 1020 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
976 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1021 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
977 | 1022 |
978 // Navigate iframe to a data URL. The navigation happens from a script in the | 1023 // Navigate iframe to a data URL. The navigation happens from a script in the |
979 // parent frame, so the data URL should be committed in the same SiteInstance | 1024 // parent frame, so the data URL should be committed in the same SiteInstance |
980 // as the parent frame. | 1025 // as the parent frame. |
981 GURL data_url("data:text/html,dataurl"); | 1026 GURL data_url("data:text/html,dataurl"); |
982 std::string script = base::StringPrintf( | 1027 std::string script = base::StringPrintf( |
983 "setTimeout(function() {" | 1028 "setTimeout(function() {" |
984 "var iframe = document.getElementById('test');" | 1029 "var iframe = document.getElementById('test');" |
985 "iframe.onload = function() { document.title = 'LOADED'; };" | 1030 "iframe.onload = function() { document.title = 'LOADED'; };" |
986 "iframe.src=\"%s\";" | 1031 "iframe.src=\"%s\";" |
987 "},0);", | 1032 "},0);", |
988 data_url.spec().c_str()); | 1033 data_url.spec().c_str()); |
989 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); | 1034 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
990 TitleWatcher title_watcher(shell()->web_contents(), passed_string); | 1035 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
991 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 1036 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
992 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); | 1037 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); |
993 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1038 EXPECT_TRUE(observer.navigation_succeeded()); |
994 EXPECT_EQ(data_url, observer.last_navigation_url()); | 1039 EXPECT_EQ(data_url, observer.navigation_url()); |
995 | 1040 |
996 // Ensure that we have navigated using the top level process. | 1041 // Ensure that we have navigated using the top level process. |
997 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 1042 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
998 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1043 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
999 } | 1044 } |
1000 | 1045 |
1001 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. | 1046 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. |
1002 // Disabled due to the same reason as NavigateRemoteToDataURL. | 1047 // Disabled due to the same reason as NavigateRemoteToDataURL. |
1003 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1048 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1004 DISABLED_NavigateRemoteToBlankURL) { | 1049 DISABLED_NavigateRemoteToBlankURL) { |
1005 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 1050 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
1006 NavigateToURL(shell(), main_url); | 1051 NavigateToURL(shell(), main_url); |
1007 | 1052 |
1008 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1053 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1009 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1054 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1010 ->GetFrameTree() | 1055 ->GetFrameTree() |
1011 ->root(); | 1056 ->root(); |
1012 | 1057 |
1013 TestNavigationObserver observer(shell()->web_contents()); | 1058 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
1014 | 1059 |
1015 // Load cross-site page into iframe. | 1060 // Load cross-site page into iframe. |
1016 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); | 1061 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
1017 NavigateFrameToURL(root->child_at(0), url); | 1062 NavigateFrameToURL(root->child_at(0), url); |
1018 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1063 EXPECT_TRUE(observer.navigation_succeeded()); |
1019 EXPECT_EQ(url, observer.last_navigation_url()); | 1064 EXPECT_EQ(url, observer.navigation_url()); |
1020 | 1065 |
1021 // Ensure that we have created a new process for the subframe. | 1066 // Ensure that we have created a new process for the subframe. |
1022 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 1067 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
1023 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1068 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1024 | 1069 |
1025 // Navigate iframe to about:blank. The navigation happens from a script in the | 1070 // Navigate iframe to about:blank. The navigation happens from a script in the |
1026 // parent frame, so it should be committed in the same SiteInstance as the | 1071 // parent frame, so it should be committed in the same SiteInstance as the |
1027 // parent frame. | 1072 // parent frame. |
1028 GURL about_blank_url("about:blank"); | 1073 GURL about_blank_url("about:blank"); |
1029 std::string script = base::StringPrintf( | 1074 std::string script = base::StringPrintf( |
1030 "setTimeout(function() {" | 1075 "setTimeout(function() {" |
1031 "var iframe = document.getElementById('test');" | 1076 "var iframe = document.getElementById('test');" |
1032 "iframe.onload = function() { document.title = 'LOADED'; };" | 1077 "iframe.onload = function() { document.title = 'LOADED'; };" |
1033 "iframe.src=\"%s\";" | 1078 "iframe.src=\"%s\";" |
1034 "},0);", | 1079 "},0);", |
1035 about_blank_url.spec().c_str()); | 1080 about_blank_url.spec().c_str()); |
1036 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); | 1081 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
1037 TitleWatcher title_watcher(shell()->web_contents(), passed_string); | 1082 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
1038 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 1083 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
1039 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); | 1084 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); |
1040 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1085 EXPECT_TRUE(observer.navigation_succeeded()); |
1041 EXPECT_EQ(about_blank_url, observer.last_navigation_url()); | 1086 EXPECT_EQ(about_blank_url, observer.navigation_url()); |
1042 | 1087 |
1043 // Ensure that we have navigated using the top level process. | 1088 // Ensure that we have navigated using the top level process. |
1044 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 1089 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
1045 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1090 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1046 } | 1091 } |
1047 | 1092 |
1048 // Ensure that navigating subframes in --site-per-process mode properly fires | 1093 // Ensure that navigating subframes in --site-per-process mode properly fires |
1049 // the DidStopLoading event on WebContentsObserver. | 1094 // the DidStopLoading event on WebContentsObserver. |
1050 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { | 1095 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { |
1051 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 1096 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
1052 NavigateToURL(shell(), main_url); | 1097 NavigateToURL(shell(), main_url); |
1053 | 1098 |
1054 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1099 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1055 FrameTreeNode* root = | 1100 FrameTreeNode* root = |
1056 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1101 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
1057 GetFrameTree()->root(); | 1102 GetFrameTree()->root(); |
1058 | 1103 |
1059 TestNavigationObserver observer(shell()->web_contents()); | 1104 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
1060 | 1105 |
1061 // Load same-site page into iframe. | 1106 // Load same-site page into iframe. |
1062 FrameTreeNode* child = root->child_at(0); | 1107 FrameTreeNode* child = root->child_at(0); |
1063 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 1108 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
1064 NavigateFrameToURL(child, http_url); | 1109 NavigateFrameToURL(child, http_url); |
1065 EXPECT_EQ(http_url, observer.last_navigation_url()); | 1110 EXPECT_EQ(http_url, observer.navigation_url()); |
1066 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1111 EXPECT_TRUE(observer.navigation_succeeded()); |
1067 | 1112 |
1068 // Load cross-site page into iframe. | 1113 // Load cross-site page into iframe. |
1069 TestNavigationObserver nav_observer(shell()->web_contents(), 1); | 1114 TestNavigationObserver nav_observer(shell()->web_contents(), 1); |
1070 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 1115 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
1071 NavigationController::LoadURLParams params(url); | 1116 NavigationController::LoadURLParams params(url); |
1072 params.transition_type = ui::PAGE_TRANSITION_LINK; | 1117 params.transition_type = ui::PAGE_TRANSITION_LINK; |
1073 params.frame_tree_node_id = child->frame_tree_node_id(); | 1118 params.frame_tree_node_id = child->frame_tree_node_id(); |
1074 child->navigator()->GetController()->LoadURLWithParams(params); | 1119 child->navigator()->GetController()->LoadURLWithParams(params); |
1075 nav_observer.Wait(); | 1120 nav_observer.Wait(); |
1076 | 1121 |
1077 // Verify that the navigation succeeded and the expected URL was loaded. | 1122 // Verify that the navigation succeeded and the expected URL was loaded. |
1078 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1123 EXPECT_TRUE(observer.navigation_succeeded()); |
1079 EXPECT_EQ(url, observer.last_navigation_url()); | 1124 EXPECT_EQ(url, observer.navigation_url()); |
1080 } | 1125 } |
1081 | 1126 |
1082 } // namespace content | 1127 } // namespace content |
OLD | NEW |