Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2710063002: Revert of Add DidSaveScrollOrScaleState flag to prevent restoreScrollPosition... (Closed)
Patch Set: rebase update Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/common/page_state_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 "/navigation_controller/simple_page_1.html")); 1333 "/navigation_controller/simple_page_1.html"));
1334 NavigateFrameToURL(root, frame_url); 1334 NavigateFrameToURL(root, frame_url);
1335 capturer.Wait(); 1335 capturer.Wait();
1336 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( 1336 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
1337 capturer.transition(), ui::PAGE_TRANSITION_LINK)); 1337 capturer.transition(), ui::PAGE_TRANSITION_LINK));
1338 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, capturer.navigation_type()); 1338 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, capturer.navigation_type());
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 // Verify that reloading a page with url anchor scrolls to correct position. 1342 // Verify that reloading a page with url anchor scrolls to correct position.
1343 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ReloadWithUrlAnchor) { 1343 // Disabled due to flakiness: https://crbug.com/672545.
1344 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
1345 DISABLED_ReloadWithUrlAnchor) {
1344 GURL url1(embedded_test_server()->GetURL( 1346 GURL url1(embedded_test_server()->GetURL(
1345 "/navigation_controller/reload-with-url-anchor.html#d2")); 1347 "/navigation_controller/reload-with-url-anchor.html#d2"));
1346 EXPECT_TRUE(NavigateToURL(shell(), url1)); 1348 EXPECT_TRUE(NavigateToURL(shell(), url1));
1347 1349
1348 std::string script = 1350 std::string script =
1349 "domAutomationController.send(document.getElementById('div').scrollTop)"; 1351 "domAutomationController.send(document.getElementById('div').scrollTop)";
1350 int value = 0; 1352 int value = 0;
1351 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); 1353 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value));
1352 EXPECT_EQ(100, value); 1354 EXPECT_EQ(100, value);
1353 1355
1354 // Reload. 1356 // Reload.
1355 ReloadBlockUntilNavigationsComplete(shell(), 1); 1357 ReloadBlockUntilNavigationsComplete(shell(), 1);
1356 1358
1357 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value)); 1359 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), script, &value));
1358 EXPECT_EQ(100, value); 1360 EXPECT_EQ(100, value);
1359 } 1361 }
1360 1362
1361 // Verify that reloading a page with url anchor and scroll scrolls to correct
1362 // position.
1363 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
1364 ReloadWithUrlAnchorAndScroll) {
1365 GURL url1(embedded_test_server()->GetURL(
1366 "/navigation_controller/reload-with-url-anchor.html#d2"));
1367 EXPECT_TRUE(NavigateToURL(shell(), url1));
1368
1369 std::string script_scroll_down = "window.scroll(0, 10)";
1370 EXPECT_TRUE(ExecuteScript(shell(), script_scroll_down));
1371
1372 std::string get_div_scroll_top =
1373 "domAutomationController.send(document.getElementById('div').scrollTop)";
1374 std::string get_window_scroll_y =
1375 "domAutomationController.send(window.scrollY)";
1376 int div_scroll_top = 0;
1377 int window_scroll_y = 0;
1378 EXPECT_TRUE(
1379 ExecuteScriptAndExtractInt(shell(), get_div_scroll_top, &div_scroll_top));
1380 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), get_window_scroll_y,
1381 &window_scroll_y));
1382 EXPECT_EQ(100, div_scroll_top);
1383 EXPECT_EQ(10, window_scroll_y);
1384
1385 // Reload.
1386 ReloadBlockUntilNavigationsComplete(shell(), 1);
1387
1388 EXPECT_TRUE(
1389 ExecuteScriptAndExtractInt(shell(), get_div_scroll_top, &div_scroll_top));
1390 EXPECT_TRUE(ExecuteScriptAndExtractInt(shell(), get_window_scroll_y,
1391 &window_scroll_y));
1392 EXPECT_EQ(100, div_scroll_top);
1393 EXPECT_EQ(10, window_scroll_y);
1394 }
1395
1396 // Verify that empty GURL navigations are not classified as SAME_PAGE. 1363 // Verify that empty GURL navigations are not classified as SAME_PAGE.
1397 // See https://crbug.com/534980. 1364 // See https://crbug.com/534980.
1398 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 1365 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
1399 NavigationTypeClassification_EmptyGURL) { 1366 NavigationTypeClassification_EmptyGURL) {
1400 GURL url1(embedded_test_server()->GetURL( 1367 GURL url1(embedded_test_server()->GetURL(
1401 "/navigation_controller/simple_page_1.html")); 1368 "/navigation_controller/simple_page_1.html"));
1402 EXPECT_TRUE(NavigateToURL(shell(), url1)); 1369 EXPECT_TRUE(NavigateToURL(shell(), url1));
1403 1370
1404 FrameTreeNode* root = 1371 FrameTreeNode* root =
1405 static_cast<WebContentsImpl*>(shell()->web_contents())-> 1372 static_cast<WebContentsImpl*>(shell()->web_contents())->
(...skipping 5409 matching lines...) Expand 10 before | Expand all | Expand 10 after
6815 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); 6782 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
6816 6783
6817 TestNavigationObserver back_observer(shell()->web_contents()); 6784 TestNavigationObserver back_observer(shell()->web_contents());
6818 controller.GoBack(); 6785 controller.GoBack();
6819 back_observer.Wait(); 6786 back_observer.Wait();
6820 6787
6821 EXPECT_TRUE(back_observer.last_navigation_succeeded()); 6788 EXPECT_TRUE(back_observer.last_navigation_succeeded());
6822 } 6789 }
6823 6790
6824 } // namespace content 6791 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/page_state_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698