OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 // Restore the session by calling chrome::Navigate(). | 1274 // Restore the session by calling chrome::Navigate(). |
1275 Browser* new_browser = | 1275 Browser* new_browser = |
1276 QuitBrowserAndRestoreWithURL(browser(), 3, url3_, true); | 1276 QuitBrowserAndRestoreWithURL(browser(), 3, url3_, true); |
1277 ASSERT_EQ(1u, active_browser_list_->size()); | 1277 ASSERT_EQ(1u, active_browser_list_->size()); |
1278 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); | 1278 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); |
1279 // Navigated url should be the active tab. | 1279 // Navigated url should be the active tab. |
1280 ASSERT_EQ(url3_, | 1280 ASSERT_EQ(url3_, |
1281 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 1281 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
1282 } | 1282 } |
1283 | 1283 |
| 1284 // Ensure that AUTO_SUBFRAME navigations in subframes are restored. |
| 1285 // See https://crbug.com/638088. |
| 1286 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreAfterAutoSubframe) { |
| 1287 // Load a page with a blank iframe, then navigate the iframe. This will be an |
| 1288 // auto-subframe commit, and we expect it to be restored. |
| 1289 GURL main_url(ui_test_utils::GetTestUrl( |
| 1290 base::FilePath(base::FilePath::kCurrentDirectory), |
| 1291 base::FilePath(FILE_PATH_LITERAL("iframe_blank.html")))); |
| 1292 GURL subframe_url(ui_test_utils::GetTestUrl( |
| 1293 base::FilePath(base::FilePath::kCurrentDirectory), |
| 1294 base::FilePath(FILE_PATH_LITERAL("title1.html")))); |
| 1295 ui_test_utils::NavigateToURL(browser(), main_url); |
| 1296 content::TestNavigationObserver observer( |
| 1297 browser()->tab_strip_model()->GetActiveWebContents()); |
| 1298 std::string nav_frame_script = |
| 1299 "frames[0].location.href = '" + subframe_url.spec() + "';"; |
| 1300 ASSERT_TRUE(content::ExecuteScript( |
| 1301 browser()->tab_strip_model()->GetActiveWebContents(), nav_frame_script)); |
| 1302 observer.Wait(); |
| 1303 |
| 1304 // Restore the session. |
| 1305 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 1306 ASSERT_EQ(1u, active_browser_list_->size()); |
| 1307 ASSERT_EQ(1, new_browser->tab_strip_model()->count()); |
| 1308 |
| 1309 // The restored page should have the right iframe. |
| 1310 ASSERT_EQ(main_url, |
| 1311 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 1312 std::string actual_frame_url; |
| 1313 std::string frame_url_script = |
| 1314 "window.domAutomationController.send(" |
| 1315 "frames[0].location.href);"; |
| 1316 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 1317 new_browser->tab_strip_model()->GetActiveWebContents(), frame_url_script, |
| 1318 &actual_frame_url)); |
| 1319 EXPECT_EQ(subframe_url.possibly_invalid_spec(), actual_frame_url); |
| 1320 } |
| 1321 |
1284 // Do a clobber restore from the new tab page. This test follows the code path | 1322 // Do a clobber restore from the new tab page. This test follows the code path |
1285 // of a crash followed by the user clicking restore from the new tab page. | 1323 // of a crash followed by the user clicking restore from the new tab page. |
1286 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClobberRestoreTest) { | 1324 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClobberRestoreTest) { |
1287 // Create 2 tabs. | 1325 // Create 2 tabs. |
1288 ui_test_utils::NavigateToURL(browser(), url1_); | 1326 ui_test_utils::NavigateToURL(browser(), url1_); |
1289 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); | 1327 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); |
1290 ui_test_utils::NavigateToURLWithDisposition( | 1328 ui_test_utils::NavigateToURLWithDisposition( |
1291 browser(), url2_, NEW_FOREGROUND_TAB, | 1329 browser(), url2_, NEW_FOREGROUND_TAB, |
1292 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1330 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1293 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); | 1331 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 // automatically at the start of the test. | 1506 // automatically at the start of the test. |
1469 for (size_t i = 1; i < web_contents().size(); i++) { | 1507 for (size_t i = 1; i < web_contents().size(); i++) { |
1470 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1508 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
1471 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1509 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
1472 if (i > 0) { | 1510 if (i > 0) { |
1473 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1511 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
1474 web_contents()[i]->GetLastActiveTime()); | 1512 web_contents()[i]->GetLastActiveTime()); |
1475 } | 1513 } |
1476 } | 1514 } |
1477 } | 1515 } |
OLD | NEW |