| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 "/navigation_controller/simple_page_1.html")); | 1328 "/navigation_controller/simple_page_1.html")); |
| 1329 NavigateFrameToURL(root, frame_url); | 1329 NavigateFrameToURL(root, frame_url); |
| 1330 capturer.Wait(); | 1330 capturer.Wait(); |
| 1331 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1331 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
| 1332 capturer.transition(), ui::PAGE_TRANSITION_LINK)); | 1332 capturer.transition(), ui::PAGE_TRANSITION_LINK)); |
| 1333 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, capturer.navigation_type()); | 1333 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, capturer.navigation_type()); |
| 1334 } | 1334 } |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 // Verify that reloading a page with url anchor scrolls to correct position. | 1337 // Verify that reloading a page with url anchor scrolls to correct position. |
| 1338 // Disabled due to flakiness: https://crbug.com/672545. | 1338 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ReloadWithUrlAnchor) { |
| 1339 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | |
| 1340 DISABLED_ReloadWithUrlAnchor) { | |
| 1341 GURL url1(embedded_test_server()->GetURL( | 1339 GURL url1(embedded_test_server()->GetURL( |
| 1342 "/navigation_controller/reload-with-url-anchor.html#d2")); | 1340 "/navigation_controller/reload-with-url-anchor.html#d2")); |
| 1343 EXPECT_TRUE(NavigateToURL(shell(), url1)); | 1341 EXPECT_TRUE(NavigateToURL(shell(), url1)); |
| 1344 | 1342 |
| 1345 std::string script = | 1343 std::string script = |
| 1346 "domAutomationController.send(document.getElementById('div').scrollTop)"; | 1344 "domAutomationController.send(document.getElementById('div').scrollTop)"; |
| 1347 int value = 0; | 1345 int value = 0; |
| 1348 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); | 1346 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); |
| 1349 EXPECT_EQ(100, value); | 1347 EXPECT_EQ(100, value); |
| 1350 | 1348 |
| 1351 // Reload. | 1349 // Reload. |
| 1352 ReloadBlockUntilNavigationsComplete(shell(), 1); | 1350 ReloadBlockUntilNavigationsComplete(shell(), 1); |
| 1353 | 1351 |
| 1354 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); | 1352 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); |
| 1355 EXPECT_EQ(100, value); | 1353 EXPECT_EQ(100, value); |
| 1356 } | 1354 } |
| 1357 | 1355 |
| 1356 // Verify that reloading a page with url anchor and scroll scrolls to correct |
| 1357 // position. |
| 1358 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1359 ReloadWithUrlAnchorAndScroll) { |
| 1360 GURL url1(embedded_test_server()->GetURL( |
| 1361 "/navigation_controller/reload-with-url-anchor.html#d2")); |
| 1362 EXPECT_TRUE(NavigateToURL(shell(), url1)); |
| 1363 |
| 1364 std::string script_scroll_down = "window.scroll(0, 10)"; |
| 1365 EXPECT_TRUE(ExecuteScript(shell(), script_scroll_down)); |
| 1366 |
| 1367 std::string get_div_scroll_top = |
| 1368 "domAutomationController.send(document.getElementById('div').scrollTop)"; |
| 1369 std::string get_window_scroll_y = |
| 1370 "domAutomationController.send(window.scrollY)"; |
| 1371 int div_scroll_top = 0; |
| 1372 int window_scroll_y = 0; |
| 1373 EXPECT_TRUE( |
| 1374 ExecuteScriptAndExtractInt(shell(), get_div_scroll_top, &div_scroll_top)); |
| 1375 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), get_window_scroll_y, |
| 1376 &window_scroll_y)); |
| 1377 EXPECT_EQ(100, div_scroll_top); |
| 1378 EXPECT_EQ(10, window_scroll_y); |
| 1379 |
| 1380 // Reload. |
| 1381 ReloadBlockUntilNavigationsComplete(shell(), 1); |
| 1382 |
| 1383 EXPECT_TRUE( |
| 1384 ExecuteScriptAndExtractInt(shell(), get_div_scroll_top, &div_scroll_top)); |
| 1385 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), get_window_scroll_y, |
| 1386 &window_scroll_y)); |
| 1387 EXPECT_EQ(100, div_scroll_top); |
| 1388 EXPECT_EQ(10, window_scroll_y); |
| 1389 } |
| 1390 |
| 1358 // Verify that empty GURL navigations are not classified as SAME_PAGE. | 1391 // Verify that empty GURL navigations are not classified as SAME_PAGE. |
| 1359 // See https://crbug.com/534980. | 1392 // See https://crbug.com/534980. |
| 1360 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1393 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1361 NavigationTypeClassification_EmptyGURL) { | 1394 NavigationTypeClassification_EmptyGURL) { |
| 1362 GURL url1(embedded_test_server()->GetURL( | 1395 GURL url1(embedded_test_server()->GetURL( |
| 1363 "/navigation_controller/simple_page_1.html")); | 1396 "/navigation_controller/simple_page_1.html")); |
| 1364 EXPECT_TRUE(NavigateToURL(shell(), url1)); | 1397 EXPECT_TRUE(NavigateToURL(shell(), url1)); |
| 1365 | 1398 |
| 1366 FrameTreeNode* root = | 1399 FrameTreeNode* root = |
| 1367 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1400 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| (...skipping 5363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6731 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), | 6764 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
| 6732 kFragmentURL); | 6765 kFragmentURL); |
| 6733 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 6766 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
| 6734 | 6767 |
| 6735 EXPECT_TRUE(handle_observer.has_committed()); | 6768 EXPECT_TRUE(handle_observer.has_committed()); |
| 6736 EXPECT_TRUE(handle_observer.was_same_page()); | 6769 EXPECT_TRUE(handle_observer.was_same_page()); |
| 6737 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 6770 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
| 6738 } | 6771 } |
| 6739 | 6772 |
| 6740 } // namespace content | 6773 } // namespace content |
| OLD | NEW |