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" |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 // Navigate the second iframe (node3) to a URL in its own process. | 1346 // Navigate the second iframe (node3) to a URL in its own process. |
1347 GURL title_url = embedded_test_server()->GetURL("/title2.html"); | 1347 GURL title_url = embedded_test_server()->GetURL("/title2.html"); |
1348 NavigateFrameToURL(node3, title_url); | 1348 NavigateFrameToURL(node3, title_url); |
1349 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1349 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1350 EXPECT_EQ(title_url, observer.last_navigation_url()); | 1350 EXPECT_EQ(title_url, observer.last_navigation_url()); |
1351 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), | 1351 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), |
1352 node3->current_frame_host()->GetSiteInstance()); | 1352 node3->current_frame_host()->GetSiteInstance()); |
1353 EXPECT_TRUE(node3->current_frame_host()->IsRenderFrameLive()); | 1353 EXPECT_TRUE(node3->current_frame_host()->IsRenderFrameLive()); |
1354 } | 1354 } |
1355 | 1355 |
| 1356 // Verify that load events for iframe elements work when the child frame is |
| 1357 // out-of-process. In such cases, the load event is forwarded from the child |
| 1358 // frame to the parent frame via the browser process. |
| 1359 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, LoadEventForwarding) { |
| 1360 // Load a page with a cross-site frame. The parent page has an onload |
| 1361 // handler in the iframe element that appends "LOADED" to the document title. |
| 1362 { |
| 1363 GURL main_url( |
| 1364 embedded_test_server()->GetURL("/frame_with_load_event.html")); |
| 1365 base::string16 expected_title(base::UTF8ToUTF16("LOADED")); |
| 1366 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 1367 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1368 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
| 1369 } |
| 1370 |
| 1371 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1372 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1373 ->GetFrameTree() |
| 1374 ->root(); |
| 1375 |
| 1376 // Load another cross-site page into the iframe and check that the load event |
| 1377 // is fired. |
| 1378 { |
| 1379 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
| 1380 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED")); |
| 1381 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 1382 TestNavigationObserver observer(shell()->web_contents()); |
| 1383 NavigateFrameToURL(root->child_at(0), foo_url); |
| 1384 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1385 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
| 1386 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
| 1387 } |
| 1388 } |
| 1389 |
1356 } // namespace content | 1390 } // namespace content |
OLD | NEW |