| 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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 params.transition_type = ui::PAGE_TRANSITION_LINK; | 1311 params.transition_type = ui::PAGE_TRANSITION_LINK; |
| 1312 params.frame_tree_node_id = child->frame_tree_node_id(); | 1312 params.frame_tree_node_id = child->frame_tree_node_id(); |
| 1313 child->navigator()->GetController()->LoadURLWithParams(params); | 1313 child->navigator()->GetController()->LoadURLWithParams(params); |
| 1314 nav_observer.Wait(); | 1314 nav_observer.Wait(); |
| 1315 | 1315 |
| 1316 // Verify that the navigation succeeded and the expected URL was loaded. | 1316 // Verify that the navigation succeeded and the expected URL was loaded. |
| 1317 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1317 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1318 EXPECT_EQ(url, observer.last_navigation_url()); | 1318 EXPECT_EQ(url, observer.last_navigation_url()); |
| 1319 } | 1319 } |
| 1320 | 1320 |
| 1321 // Verify that load events for iframe elements work when the child frame is |
| 1322 // out-of-process. In such cases, the load event is forwarded from the child |
| 1323 // frame to the parent frame via the browser process. |
| 1324 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, LoadEventForwarding) { |
| 1325 // Load a page with a cross-site frame. The parent page has an onload |
| 1326 // handler in the iframe element that appends "LOADED" to the document title. |
| 1327 { |
| 1328 GURL main_url( |
| 1329 embedded_test_server()->GetURL("/frame_with_load_event.html")); |
| 1330 base::string16 expected_title(base::UTF8ToUTF16("LOADED")); |
| 1331 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 1332 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1333 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
| 1334 } |
| 1335 |
| 1336 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1337 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1338 ->GetFrameTree() |
| 1339 ->root(); |
| 1340 |
| 1341 // Load another cross-site page into the iframe and check that the load event |
| 1342 // is fired. |
| 1343 { |
| 1344 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
| 1345 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED")); |
| 1346 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 1347 TestNavigationObserver observer(shell()->web_contents()); |
| 1348 NavigateFrameToURL(root->child_at(0), foo_url); |
| 1349 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1350 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
| 1351 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
| 1352 } |
| 1353 } |
| 1354 |
| 1321 } // namespace content | 1355 } // namespace content |
| OLD | NEW |