| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 // TODO(boliu): Add test for in-page fragment navigation. See | 187 // TODO(boliu): Add test for in-page fragment navigation. See |
| 188 // crbug.com/561034. | 188 // crbug.com/561034. |
| 189 | 189 |
| 190 // Navigate with Javascript. | 190 // Navigate with Javascript. |
| 191 { | 191 { |
| 192 GURL navigate_url = embedded_test_server()->base_url(); | 192 GURL navigate_url = embedded_test_server()->base_url(); |
| 193 std::string script = "document.location = '" + | 193 std::string script = "document.location = '" + |
| 194 navigate_url.spec() + "';"; | 194 navigate_url.spec() + "';"; |
| 195 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1); | 195 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1); |
| 196 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 196 EXPECT_TRUE(ExecuteScript(shell(), script)); |
| 197 same_tab_observer.Wait(); | 197 same_tab_observer.Wait(); |
| 198 EXPECT_EQ(2, controller.GetEntryCount()); | 198 EXPECT_EQ(2, controller.GetEntryCount()); |
| 199 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 199 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 200 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); | 200 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); |
| 201 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); | 201 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); |
| 202 EXPECT_EQ(navigate_url, entry->GetVirtualURL()); | 202 EXPECT_EQ(navigate_url, entry->GetVirtualURL()); |
| 203 EXPECT_EQ(navigate_url, entry->GetURL()); | 203 EXPECT_EQ(navigate_url, entry->GetURL()); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 233 NavigateToURL(shell(), js_url); | 233 NavigateToURL(shell(), js_url); |
| 234 EXPECT_EQ(2, controller.GetEntryCount()); | 234 EXPECT_EQ(2, controller.GetEntryCount()); |
| 235 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 235 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 236 // TODO(boliu): These expectations maybe incorrect due to crbug.com/561034. | 236 // TODO(boliu): These expectations maybe incorrect due to crbug.com/561034. |
| 237 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); | 237 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); |
| 238 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); | 238 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); |
| 239 EXPECT_EQ(data_url, entry->GetVirtualURL()); | 239 EXPECT_EQ(data_url, entry->GetVirtualURL()); |
| 240 EXPECT_EQ(data_url, entry->GetURL()); | 240 EXPECT_EQ(data_url, entry->GetURL()); |
| 241 | 241 |
| 242 // Passes if renderer is still alive. | 242 // Passes if renderer is still alive. |
| 243 EXPECT_TRUE( | 243 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');")); |
| 244 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | |
| 245 } | 244 } |
| 246 | 245 |
| 247 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { | 246 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { |
| 248 const NavigationControllerImpl& controller = | 247 const NavigationControllerImpl& controller = |
| 249 static_cast<const NavigationControllerImpl&>( | 248 static_cast<const NavigationControllerImpl&>( |
| 250 shell()->web_contents()->GetController()); | 249 shell()->web_contents()->GetController()); |
| 251 | 250 |
| 252 GURL main_url(embedded_test_server()->GetURL( | 251 GURL main_url(embedded_test_server()->GetURL( |
| 253 "/navigation_controller/page_with_link_to_load_iframe.html")); | 252 "/navigation_controller/page_with_link_to_load_iframe.html")); |
| 254 NavigateToURL(shell(), main_url); | 253 NavigateToURL(shell(), main_url); |
| 255 ASSERT_EQ(1, controller.GetEntryCount()); | 254 ASSERT_EQ(1, controller.GetEntryCount()); |
| 256 | 255 |
| 257 // Use JavaScript to click the link and load the iframe. | 256 // Use JavaScript to click the link and load the iframe. |
| 258 std::string script = "document.getElementById('link').click()"; | 257 std::string script = "document.getElementById('link').click()"; |
| 259 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 258 EXPECT_TRUE(ExecuteScript(shell(), script)); |
| 260 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 259 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 261 ASSERT_EQ(2, controller.GetEntryCount()); | 260 ASSERT_EQ(2, controller.GetEntryCount()); |
| 262 | 261 |
| 263 // Unique IDs should... um... be unique. | 262 // Unique IDs should... um... be unique. |
| 264 ASSERT_NE(controller.GetEntryAtIndex(0)->GetUniqueID(), | 263 ASSERT_NE(controller.GetEntryAtIndex(0)->GetUniqueID(), |
| 265 controller.GetEntryAtIndex(1)->GetUniqueID()); | 264 controller.GetEntryAtIndex(1)->GetUniqueID()); |
| 266 } | 265 } |
| 267 | 266 |
| 268 // Ensures that RenderFrameHosts end up with the correct nav_entry_id() after | 267 // Ensures that RenderFrameHosts end up with the correct nav_entry_id() after |
| 269 // navigations. | 268 // navigations. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // This should have successfully gone back. | 353 // This should have successfully gone back. |
| 355 EXPECT_EQ(GURL(base::StringPrintf("data:text/html,page%d", kMaxEntryCount)), | 354 EXPECT_EQ(GURL(base::StringPrintf("data:text/html,page%d", kMaxEntryCount)), |
| 356 controller.GetLastCommittedEntry()->GetURL()); | 355 controller.GetLastCommittedEntry()->GetURL()); |
| 357 } | 356 } |
| 358 | 357 |
| 359 namespace { | 358 namespace { |
| 360 | 359 |
| 361 int RendererHistoryLength(Shell* shell) { | 360 int RendererHistoryLength(Shell* shell) { |
| 362 int value = 0; | 361 int value = 0; |
| 363 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 362 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 364 shell->web_contents(), | 363 shell, "domAutomationController.send(history.length)", &value)); |
| 365 "domAutomationController.send(history.length)", | |
| 366 &value)); | |
| 367 return value; | 364 return value; |
| 368 } | 365 } |
| 369 | 366 |
| 370 // Similar to the ones from content_browser_test_utils. | 367 // Similar to the ones from content_browser_test_utils. |
| 371 bool NavigateToURLAndReplace(Shell* shell, const GURL& url) { | 368 bool NavigateToURLAndReplace(Shell* shell, const GURL& url) { |
| 372 WebContents* web_contents = shell->web_contents(); | 369 WebContents* web_contents = shell->web_contents(); |
| 373 WaitForLoadStop(web_contents); | 370 WaitForLoadStop(web_contents); |
| 374 TestNavigationObserver same_tab_observer(web_contents, 1); | 371 TestNavigationObserver same_tab_observer(web_contents, 1); |
| 375 NavigationController::LoadURLParams params(url); | 372 NavigationController::LoadURLParams params(url); |
| 376 params.should_replace_current_entry = true; | 373 params.should_replace_current_entry = true; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 CorrectLengthWithNewTabNavigatingFromWebUI) { | 430 CorrectLengthWithNewTabNavigatingFromWebUI) { |
| 434 GURL web_ui_page(std::string(kChromeUIScheme) + "://" + | 431 GURL web_ui_page(std::string(kChromeUIScheme) + "://" + |
| 435 std::string(kChromeUIGpuHost)); | 432 std::string(kChromeUIGpuHost)); |
| 436 EXPECT_TRUE(NavigateToURL(shell(), web_ui_page)); | 433 EXPECT_TRUE(NavigateToURL(shell(), web_ui_page)); |
| 437 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, | 434 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, |
| 438 shell()->web_contents()->GetRenderViewHost()->GetEnabledBindings()); | 435 shell()->web_contents()->GetRenderViewHost()->GetEnabledBindings()); |
| 439 | 436 |
| 440 ShellAddedObserver observer; | 437 ShellAddedObserver observer; |
| 441 std::string page_url = embedded_test_server()->GetURL( | 438 std::string page_url = embedded_test_server()->GetURL( |
| 442 "/navigation_controller/simple_page_1.html").spec(); | 439 "/navigation_controller/simple_page_1.html").spec(); |
| 443 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 440 EXPECT_TRUE( |
| 444 "window.open('" + page_url + "', '_blank')")); | 441 ExecuteScript(shell(), "window.open('" + page_url + "', '_blank')")); |
| 445 Shell* shell2 = observer.GetShell(); | 442 Shell* shell2 = observer.GetShell(); |
| 446 EXPECT_TRUE(WaitForLoadStop(shell2->web_contents())); | 443 EXPECT_TRUE(WaitForLoadStop(shell2->web_contents())); |
| 447 | 444 |
| 448 EXPECT_EQ(1, shell2->web_contents()->GetController().GetEntryCount()); | 445 EXPECT_EQ(1, shell2->web_contents()->GetController().GetEntryCount()); |
| 449 EXPECT_EQ(1, RendererHistoryLength(shell2)); | 446 EXPECT_EQ(1, RendererHistoryLength(shell2)); |
| 450 | 447 |
| 451 // Again, as above, there's no way to access the renderer's notion of the | 448 // Again, as above, there's no way to access the renderer's notion of the |
| 452 // history offset via JavaScript. Checking just the history length, again, | 449 // history offset via JavaScript. Checking just the history length, again, |
| 453 // will have to suffice. | 450 // will have to suffice. |
| 454 } | 451 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 // Navigate to a page to force the renderer process to start. | 667 // Navigate to a page to force the renderer process to start. |
| 671 EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL))); | 668 EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL))); |
| 672 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 669 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 673 ->GetFrameTree() | 670 ->GetFrameTree() |
| 674 ->root(); | 671 ->root(); |
| 675 | 672 |
| 676 // Pop open a new window with no last committed entry. | 673 // Pop open a new window with no last committed entry. |
| 677 ShellAddedObserver new_shell_observer; | 674 ShellAddedObserver new_shell_observer; |
| 678 { | 675 { |
| 679 std::string script = "window.open()"; | 676 std::string script = "window.open()"; |
| 680 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 677 EXPECT_TRUE(ExecuteScript(root, script)); |
| 681 } | 678 } |
| 682 Shell* new_shell = new_shell_observer.GetShell(); | 679 Shell* new_shell = new_shell_observer.GetShell(); |
| 683 ASSERT_NE(new_shell->web_contents(), shell()->web_contents()); | 680 ASSERT_NE(new_shell->web_contents(), shell()->web_contents()); |
| 684 FrameTreeNode* new_root = | 681 FrameTreeNode* new_root = |
| 685 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 682 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
| 686 ->GetFrameTree() | 683 ->GetFrameTree() |
| 687 ->root(); | 684 ->root(); |
| 688 EXPECT_FALSE( | 685 EXPECT_FALSE( |
| 689 new_shell->web_contents()->GetController().GetLastCommittedEntry()); | 686 new_shell->web_contents()->GetController().GetLastCommittedEntry()); |
| 690 | 687 |
| 691 // Make a new iframe in it. | 688 // Make a new iframe in it. |
| 692 NoNavigationsObserver observer(new_shell->web_contents()); | 689 NoNavigationsObserver observer(new_shell->web_contents()); |
| 693 { | 690 { |
| 694 LoadCommittedCapturer capturer(new_shell->web_contents()); | 691 LoadCommittedCapturer capturer(new_shell->web_contents()); |
| 695 std::string script = "var iframe = document.createElement('iframe');" | 692 std::string script = "var iframe = document.createElement('iframe');" |
| 696 "iframe.src = 'data:text/html,<p>some page</p>';" | 693 "iframe.src = 'data:text/html,<p>some page</p>';" |
| 697 "document.body.appendChild(iframe);"; | 694 "document.body.appendChild(iframe);"; |
| 698 EXPECT_TRUE(ExecuteScript(new_root->current_frame_host(), script)); | 695 EXPECT_TRUE(ExecuteScript(new_root, script)); |
| 699 capturer.Wait(); | 696 capturer.Wait(); |
| 700 } | 697 } |
| 701 ASSERT_EQ(1U, new_root->child_count()); | 698 ASSERT_EQ(1U, new_root->child_count()); |
| 702 ASSERT_NE(nullptr, new_root->child_at(0)); | 699 ASSERT_NE(nullptr, new_root->child_at(0)); |
| 703 | 700 |
| 704 // Navigate it cross-site. | 701 // Navigate it cross-site. |
| 705 GURL frame_url = embedded_test_server()->GetURL( | 702 GURL frame_url = embedded_test_server()->GetURL( |
| 706 "foo.com", "/navigation_controller/simple_page_2.html"); | 703 "foo.com", "/navigation_controller/simple_page_2.html"); |
| 707 { | 704 { |
| 708 LoadCommittedCapturer capturer(new_shell->web_contents()); | 705 LoadCommittedCapturer capturer(new_shell->web_contents()); |
| 709 std::string script = "location.assign('" + frame_url.spec() + "')"; | 706 std::string script = "location.assign('" + frame_url.spec() + "')"; |
| 710 EXPECT_TRUE( | 707 EXPECT_TRUE(ExecuteScript(new_root->child_at(0), script)); |
| 711 ExecuteScript(new_root->child_at(0)->current_frame_host(), script)); | |
| 712 capturer.Wait(); | 708 capturer.Wait(); |
| 713 } | 709 } |
| 714 | 710 |
| 715 // Success is not crashing, and not navigating. | 711 // Success is not crashing, and not navigating. |
| 716 EXPECT_EQ(nullptr, | 712 EXPECT_EQ(nullptr, |
| 717 new_shell->web_contents()->GetController().GetLastCommittedEntry()); | 713 new_shell->web_contents()->GetController().GetLastCommittedEntry()); |
| 718 | 714 |
| 719 // A nested iframe with a cross-site URL should also be able to commit. | 715 // A nested iframe with a cross-site URL should also be able to commit. |
| 720 GURL grandchild_url(embedded_test_server()->GetURL( | 716 GURL grandchild_url(embedded_test_server()->GetURL( |
| 721 "bar.com", "/navigation_controller/simple_page_1.html")); | 717 "bar.com", "/navigation_controller/simple_page_1.html")); |
| 722 { | 718 { |
| 723 LoadCommittedCapturer capturer(new_shell->web_contents()); | 719 LoadCommittedCapturer capturer(new_shell->web_contents()); |
| 724 std::string script = "var iframe = document.createElement('iframe');" | 720 std::string script = "var iframe = document.createElement('iframe');" |
| 725 "iframe.src = '" + grandchild_url.spec() + "';" | 721 "iframe.src = '" + grandchild_url.spec() + "';" |
| 726 "document.body.appendChild(iframe);"; | 722 "document.body.appendChild(iframe);"; |
| 727 EXPECT_TRUE( | 723 EXPECT_TRUE(ExecuteScript(new_root->child_at(0), script)); |
| 728 ExecuteScript(new_root->child_at(0)->current_frame_host(), script)); | |
| 729 capturer.Wait(); | 724 capturer.Wait(); |
| 730 } | 725 } |
| 731 ASSERT_EQ(1U, new_root->child_at(0)->child_count()); | 726 ASSERT_EQ(1U, new_root->child_at(0)->child_count()); |
| 732 EXPECT_EQ(grandchild_url, new_root->child_at(0)->child_at(0)->current_url()); | 727 EXPECT_EQ(grandchild_url, new_root->child_at(0)->child_at(0)->current_url()); |
| 733 } | 728 } |
| 734 | 729 |
| 735 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 730 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 736 ErrorPageReplacement) { | 731 ErrorPageReplacement) { |
| 737 NavigationController& controller = shell()->web_contents()->GetController(); | 732 NavigationController& controller = shell()->web_contents()->GetController(); |
| 738 GURL error_url( | 733 GURL error_url( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // transition? Lots of these transitions should be cleaned up. | 830 // transition? Lots of these transitions should be cleaned up. |
| 836 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); | 831 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); |
| 837 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 832 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 838 EXPECT_FALSE(capturer.details().is_in_page); | 833 EXPECT_FALSE(capturer.details().is_in_page); |
| 839 } | 834 } |
| 840 | 835 |
| 841 { | 836 { |
| 842 // Load via a fragment link click. | 837 // Load via a fragment link click. |
| 843 FrameNavigateParamsCapturer capturer(root); | 838 FrameNavigateParamsCapturer capturer(root); |
| 844 std::string script = "document.getElementById('fraglink').click()"; | 839 std::string script = "document.getElementById('fraglink').click()"; |
| 845 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 840 EXPECT_TRUE(ExecuteScript(root, script)); |
| 846 capturer.Wait(); | 841 capturer.Wait(); |
| 847 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); | 842 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); |
| 848 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 843 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 849 EXPECT_TRUE(capturer.details().is_in_page); | 844 EXPECT_TRUE(capturer.details().is_in_page); |
| 850 } | 845 } |
| 851 | 846 |
| 852 { | 847 { |
| 853 // Load via link click. | 848 // Load via link click. |
| 854 FrameNavigateParamsCapturer capturer(root); | 849 FrameNavigateParamsCapturer capturer(root); |
| 855 std::string script = "document.getElementById('thelink').click()"; | 850 std::string script = "document.getElementById('thelink').click()"; |
| 856 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 851 EXPECT_TRUE(ExecuteScript(root, script)); |
| 857 capturer.Wait(); | 852 capturer.Wait(); |
| 858 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); | 853 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); |
| 859 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 854 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 860 EXPECT_FALSE(capturer.details().is_in_page); | 855 EXPECT_FALSE(capturer.details().is_in_page); |
| 861 } | 856 } |
| 862 | 857 |
| 863 { | 858 { |
| 864 // location.assign(). | 859 // location.assign(). |
| 865 FrameNavigateParamsCapturer capturer(root); | 860 FrameNavigateParamsCapturer capturer(root); |
| 866 GURL frame_url(embedded_test_server()->GetURL( | 861 GURL frame_url(embedded_test_server()->GetURL( |
| 867 "/navigation_controller/simple_page_2.html")); | 862 "/navigation_controller/simple_page_2.html")); |
| 868 std::string script = "location.assign('" + frame_url.spec() + "')"; | 863 std::string script = "location.assign('" + frame_url.spec() + "')"; |
| 869 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 864 EXPECT_TRUE(ExecuteScript(root, script)); |
| 870 capturer.Wait(); | 865 capturer.Wait(); |
| 871 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 866 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 872 capturer.params().transition); | 867 capturer.params().transition); |
| 873 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 868 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 874 EXPECT_FALSE(capturer.details().is_in_page); | 869 EXPECT_FALSE(capturer.details().is_in_page); |
| 875 } | 870 } |
| 876 | 871 |
| 877 { | 872 { |
| 878 // history.pushState(). | 873 // history.pushState(). |
| 879 FrameNavigateParamsCapturer capturer(root); | 874 FrameNavigateParamsCapturer capturer(root); |
| 880 std::string script = | 875 std::string script = |
| 881 "history.pushState({}, 'page 1', 'simple_page_1.html')"; | 876 "history.pushState({}, 'page 1', 'simple_page_1.html')"; |
| 882 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 877 EXPECT_TRUE(ExecuteScript(root, script)); |
| 883 capturer.Wait(); | 878 capturer.Wait(); |
| 884 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 879 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 885 capturer.params().transition); | 880 capturer.params().transition); |
| 886 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 881 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 887 EXPECT_TRUE(capturer.details().is_in_page); | 882 EXPECT_TRUE(capturer.details().is_in_page); |
| 888 } | 883 } |
| 889 | 884 |
| 890 if (AreAllSitesIsolatedForTesting()) { | 885 if (AreAllSitesIsolatedForTesting()) { |
| 891 // Cross-process location.replace(). | 886 // Cross-process location.replace(). |
| 892 FrameNavigateParamsCapturer capturer(root); | 887 FrameNavigateParamsCapturer capturer(root); |
| 893 GURL frame_url(embedded_test_server()->GetURL( | 888 GURL frame_url(embedded_test_server()->GetURL( |
| 894 "foo.com", "/navigation_controller/simple_page_1.html")); | 889 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 895 std::string script = "location.replace('" + frame_url.spec() + "')"; | 890 std::string script = "location.replace('" + frame_url.spec() + "')"; |
| 896 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 891 EXPECT_TRUE(ExecuteScript(root, script)); |
| 897 capturer.Wait(); | 892 capturer.Wait(); |
| 898 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 893 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 899 capturer.params().transition); | 894 capturer.params().transition); |
| 900 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 895 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 901 EXPECT_FALSE(capturer.details().is_in_page); | 896 EXPECT_FALSE(capturer.details().is_in_page); |
| 902 } | 897 } |
| 903 } | 898 } |
| 904 | 899 |
| 905 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly | 900 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly |
| 906 // classified. | 901 // classified. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 | ui::PAGE_TRANSITION_FORWARD_BACK | 934 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 940 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 935 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| 941 capturer.params().transition); | 936 capturer.params().transition); |
| 942 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 937 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 943 EXPECT_FALSE(capturer.details().is_in_page); | 938 EXPECT_FALSE(capturer.details().is_in_page); |
| 944 } | 939 } |
| 945 | 940 |
| 946 { | 941 { |
| 947 // Back from the renderer side. | 942 // Back from the renderer side. |
| 948 FrameNavigateParamsCapturer capturer(root); | 943 FrameNavigateParamsCapturer capturer(root); |
| 949 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "history.back()")); | 944 EXPECT_TRUE(ExecuteScript(root, "history.back()")); |
| 950 capturer.Wait(); | 945 capturer.Wait(); |
| 951 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 946 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 952 | ui::PAGE_TRANSITION_FORWARD_BACK | 947 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 953 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 948 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| 954 capturer.params().transition); | 949 capturer.params().transition); |
| 955 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 950 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 956 EXPECT_FALSE(capturer.details().is_in_page); | 951 EXPECT_FALSE(capturer.details().is_in_page); |
| 957 } | 952 } |
| 958 | 953 |
| 959 { | 954 { |
| 960 // Forward from the renderer side. | 955 // Forward from the renderer side. |
| 961 FrameNavigateParamsCapturer capturer(root); | 956 FrameNavigateParamsCapturer capturer(root); |
| 962 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "history.forward()")); | 957 EXPECT_TRUE(ExecuteScript(root, "history.forward()")); |
| 963 capturer.Wait(); | 958 capturer.Wait(); |
| 964 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 959 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 965 | ui::PAGE_TRANSITION_FORWARD_BACK | 960 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 966 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 961 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| 967 capturer.params().transition); | 962 capturer.params().transition); |
| 968 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 963 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 969 EXPECT_FALSE(capturer.details().is_in_page); | 964 EXPECT_FALSE(capturer.details().is_in_page); |
| 970 } | 965 } |
| 971 | 966 |
| 972 { | 967 { |
| 973 // Back from the renderer side via history.go(). | 968 // Back from the renderer side via history.go(). |
| 974 FrameNavigateParamsCapturer capturer(root); | 969 FrameNavigateParamsCapturer capturer(root); |
| 975 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "history.go(-1)")); | 970 EXPECT_TRUE(ExecuteScript(root, "history.go(-1)")); |
| 976 capturer.Wait(); | 971 capturer.Wait(); |
| 977 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 972 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 978 | ui::PAGE_TRANSITION_FORWARD_BACK | 973 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 979 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 974 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| 980 capturer.params().transition); | 975 capturer.params().transition); |
| 981 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 976 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 982 EXPECT_FALSE(capturer.details().is_in_page); | 977 EXPECT_FALSE(capturer.details().is_in_page); |
| 983 } | 978 } |
| 984 | 979 |
| 985 { | 980 { |
| 986 // Forward from the renderer side via history.go(). | 981 // Forward from the renderer side via history.go(). |
| 987 FrameNavigateParamsCapturer capturer(root); | 982 FrameNavigateParamsCapturer capturer(root); |
| 988 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "history.go(1)")); | 983 EXPECT_TRUE(ExecuteScript(root, "history.go(1)")); |
| 989 capturer.Wait(); | 984 capturer.Wait(); |
| 990 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 985 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 991 | ui::PAGE_TRANSITION_FORWARD_BACK | 986 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 992 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 987 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| 993 capturer.params().transition); | 988 capturer.params().transition); |
| 994 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 989 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 995 EXPECT_FALSE(capturer.details().is_in_page); | 990 EXPECT_FALSE(capturer.details().is_in_page); |
| 996 } | 991 } |
| 997 | 992 |
| 998 { | 993 { |
| 999 // Reload from the browser side. | 994 // Reload from the browser side. |
| 1000 FrameNavigateParamsCapturer capturer(root); | 995 FrameNavigateParamsCapturer capturer(root); |
| 1001 shell()->web_contents()->GetController().Reload(false); | 996 shell()->web_contents()->GetController().Reload(false); |
| 1002 capturer.Wait(); | 997 capturer.Wait(); |
| 1003 EXPECT_EQ(ui::PAGE_TRANSITION_RELOAD, capturer.params().transition); | 998 EXPECT_EQ(ui::PAGE_TRANSITION_RELOAD, capturer.params().transition); |
| 1004 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 999 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 1005 EXPECT_FALSE(capturer.details().is_in_page); | 1000 EXPECT_FALSE(capturer.details().is_in_page); |
| 1006 } | 1001 } |
| 1007 | 1002 |
| 1008 { | 1003 { |
| 1009 // Reload from the renderer side. | 1004 // Reload from the renderer side. |
| 1010 FrameNavigateParamsCapturer capturer(root); | 1005 FrameNavigateParamsCapturer capturer(root); |
| 1011 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "location.reload()")); | 1006 EXPECT_TRUE(ExecuteScript(root, "location.reload()")); |
| 1012 capturer.Wait(); | 1007 capturer.Wait(); |
| 1013 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 1008 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 1014 capturer.params().transition); | 1009 capturer.params().transition); |
| 1015 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 1010 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 1016 EXPECT_FALSE(capturer.details().is_in_page); | 1011 EXPECT_FALSE(capturer.details().is_in_page); |
| 1017 } | 1012 } |
| 1018 | 1013 |
| 1019 { | 1014 { |
| 1020 // location.replace(). | 1015 // location.replace(). |
| 1021 // TODO(creis): Change this to be NEW_PAGE with replacement in | 1016 // TODO(creis): Change this to be NEW_PAGE with replacement in |
| 1022 // https://crbug.com/596707. | 1017 // https://crbug.com/596707. |
| 1023 FrameNavigateParamsCapturer capturer(root); | 1018 FrameNavigateParamsCapturer capturer(root); |
| 1024 GURL frame_url(embedded_test_server()->GetURL( | 1019 GURL frame_url(embedded_test_server()->GetURL( |
| 1025 "/navigation_controller/simple_page_1.html")); | 1020 "/navigation_controller/simple_page_1.html")); |
| 1026 std::string script = "location.replace('" + frame_url.spec() + "')"; | 1021 std::string script = "location.replace('" + frame_url.spec() + "')"; |
| 1027 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1022 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1028 capturer.Wait(); | 1023 capturer.Wait(); |
| 1029 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 1024 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 1030 capturer.params().transition); | 1025 capturer.params().transition); |
| 1031 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 1026 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 1032 EXPECT_FALSE(capturer.details().is_in_page); | 1027 EXPECT_FALSE(capturer.details().is_in_page); |
| 1033 } | 1028 } |
| 1034 | 1029 |
| 1035 // Now, various in-page navigations. | 1030 // Now, various in-page navigations. |
| 1036 | 1031 |
| 1037 { | 1032 { |
| 1038 // history.replaceState(). | 1033 // history.replaceState(). |
| 1039 FrameNavigateParamsCapturer capturer(root); | 1034 FrameNavigateParamsCapturer capturer(root); |
| 1040 std::string script = | 1035 std::string script = |
| 1041 "history.replaceState({}, 'page 2', 'simple_page_2.html')"; | 1036 "history.replaceState({}, 'page 2', 'simple_page_2.html')"; |
| 1042 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1037 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1043 capturer.Wait(); | 1038 capturer.Wait(); |
| 1044 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 1039 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 1045 capturer.params().transition); | 1040 capturer.params().transition); |
| 1046 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 1041 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 1047 EXPECT_TRUE(capturer.details().is_in_page); | 1042 EXPECT_TRUE(capturer.details().is_in_page); |
| 1048 } | 1043 } |
| 1049 | 1044 |
| 1050 // Back and forward across a fragment navigation. | 1045 // Back and forward across a fragment navigation. |
| 1051 | 1046 |
| 1052 GURL url_links(embedded_test_server()->GetURL( | 1047 GURL url_links(embedded_test_server()->GetURL( |
| 1053 "/navigation_controller/page_with_links.html")); | 1048 "/navigation_controller/page_with_links.html")); |
| 1054 NavigateToURL(shell(), url_links); | 1049 NavigateToURL(shell(), url_links); |
| 1055 std::string script = "document.getElementById('fraglink').click()"; | 1050 std::string script = "document.getElementById('fraglink').click()"; |
| 1056 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1051 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1057 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 1052 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 1058 | 1053 |
| 1059 { | 1054 { |
| 1060 // Back. | 1055 // Back. |
| 1061 FrameNavigateParamsCapturer capturer(root); | 1056 FrameNavigateParamsCapturer capturer(root); |
| 1062 shell()->web_contents()->GetController().GoBack(); | 1057 shell()->web_contents()->GetController().GoBack(); |
| 1063 capturer.Wait(); | 1058 capturer.Wait(); |
| 1064 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 1059 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 1065 | ui::PAGE_TRANSITION_FORWARD_BACK | 1060 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 1066 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 1061 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1077 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FORWARD_BACK, | 1072 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FORWARD_BACK, |
| 1078 capturer.params().transition); | 1073 capturer.params().transition); |
| 1079 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 1074 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 1080 EXPECT_TRUE(capturer.details().is_in_page); | 1075 EXPECT_TRUE(capturer.details().is_in_page); |
| 1081 } | 1076 } |
| 1082 | 1077 |
| 1083 // Back and forward across a pushState-created navigation. | 1078 // Back and forward across a pushState-created navigation. |
| 1084 | 1079 |
| 1085 NavigateToURL(shell(), url1); | 1080 NavigateToURL(shell(), url1); |
| 1086 script = "history.pushState({}, 'page 2', 'simple_page_2.html')"; | 1081 script = "history.pushState({}, 'page 2', 'simple_page_2.html')"; |
| 1087 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1082 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1088 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 1083 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 1089 | 1084 |
| 1090 { | 1085 { |
| 1091 // Back. | 1086 // Back. |
| 1092 FrameNavigateParamsCapturer capturer(root); | 1087 FrameNavigateParamsCapturer capturer(root); |
| 1093 shell()->web_contents()->GetController().GoBack(); | 1088 shell()->web_contents()->GetController().GoBack(); |
| 1094 capturer.Wait(); | 1089 capturer.Wait(); |
| 1095 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED | 1090 EXPECT_EQ(ui::PAGE_TRANSITION_TYPED |
| 1096 | ui::PAGE_TRANSITION_FORWARD_BACK | 1091 | ui::PAGE_TRANSITION_FORWARD_BACK |
| 1097 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, | 1092 | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 capturer.Wait(); | 1219 capturer.Wait(); |
| 1225 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1220 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1226 capturer.params().transition); | 1221 capturer.params().transition); |
| 1227 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1222 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1228 } | 1223 } |
| 1229 | 1224 |
| 1230 { | 1225 { |
| 1231 // Load via a fragment link click. | 1226 // Load via a fragment link click. |
| 1232 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1227 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 1233 std::string script = "document.getElementById('fraglink').click()"; | 1228 std::string script = "document.getElementById('fraglink').click()"; |
| 1234 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1229 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1235 capturer.Wait(); | 1230 capturer.Wait(); |
| 1236 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1231 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1237 capturer.params().transition); | 1232 capturer.params().transition); |
| 1238 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1233 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1239 } | 1234 } |
| 1240 | 1235 |
| 1241 { | 1236 { |
| 1242 // location.assign(). | 1237 // location.assign(). |
| 1243 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1238 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 1244 GURL frame_url(embedded_test_server()->GetURL( | 1239 GURL frame_url(embedded_test_server()->GetURL( |
| 1245 "/navigation_controller/simple_page_1.html")); | 1240 "/navigation_controller/simple_page_1.html")); |
| 1246 std::string script = "location.assign('" + frame_url.spec() + "')"; | 1241 std::string script = "location.assign('" + frame_url.spec() + "')"; |
| 1247 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1242 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1248 capturer.Wait(); | 1243 capturer.Wait(); |
| 1249 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1244 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1250 capturer.params().transition); | 1245 capturer.params().transition); |
| 1251 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1246 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1252 } | 1247 } |
| 1253 | 1248 |
| 1254 { | 1249 { |
| 1255 // location.replace(). | 1250 // location.replace(). |
| 1256 LoadCommittedCapturer capturer(root->child_at(0)); | 1251 LoadCommittedCapturer capturer(root->child_at(0)); |
| 1257 GURL frame_url(embedded_test_server()->GetURL( | 1252 GURL frame_url(embedded_test_server()->GetURL( |
| 1258 "/navigation_controller/simple_page_2.html")); | 1253 "/navigation_controller/simple_page_2.html")); |
| 1259 std::string script = "location.replace('" + frame_url.spec() + "')"; | 1254 std::string script = "location.replace('" + frame_url.spec() + "')"; |
| 1260 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1255 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1261 capturer.Wait(); | 1256 capturer.Wait(); |
| 1262 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1257 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1263 } | 1258 } |
| 1264 | 1259 |
| 1265 { | 1260 { |
| 1266 // history.pushState(). | 1261 // history.pushState(). |
| 1267 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1262 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 1268 std::string script = | 1263 std::string script = |
| 1269 "history.pushState({}, 'page 1', 'simple_page_1.html')"; | 1264 "history.pushState({}, 'page 1', 'simple_page_1.html')"; |
| 1270 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1265 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1271 capturer.Wait(); | 1266 capturer.Wait(); |
| 1272 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1267 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1273 capturer.params().transition); | 1268 capturer.params().transition); |
| 1274 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1269 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1275 } | 1270 } |
| 1276 | 1271 |
| 1277 { | 1272 { |
| 1278 // history.replaceState(). | 1273 // history.replaceState(). |
| 1279 LoadCommittedCapturer capturer(root->child_at(0)); | 1274 LoadCommittedCapturer capturer(root->child_at(0)); |
| 1280 std::string script = | 1275 std::string script = |
| 1281 "history.replaceState({}, 'page 2', 'simple_page_2.html')"; | 1276 "history.replaceState({}, 'page 2', 'simple_page_2.html')"; |
| 1282 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1277 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1283 capturer.Wait(); | 1278 capturer.Wait(); |
| 1284 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1279 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1285 } | 1280 } |
| 1286 | 1281 |
| 1287 { | 1282 { |
| 1288 // Reload. | 1283 // Reload. |
| 1289 LoadCommittedCapturer capturer(root->child_at(0)); | 1284 LoadCommittedCapturer capturer(root->child_at(0)); |
| 1290 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), | 1285 EXPECT_TRUE(ExecuteScript(root->child_at(0), "location.reload()")); |
| 1291 "location.reload()")); | |
| 1292 capturer.Wait(); | 1286 capturer.Wait(); |
| 1293 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1287 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1294 } | 1288 } |
| 1295 | 1289 |
| 1296 { | 1290 { |
| 1297 // Create an iframe. | 1291 // Create an iframe. |
| 1298 LoadCommittedCapturer capturer(shell()->web_contents()); | 1292 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1299 GURL frame_url(embedded_test_server()->GetURL( | 1293 GURL frame_url(embedded_test_server()->GetURL( |
| 1300 "/navigation_controller/simple_page_1.html")); | 1294 "/navigation_controller/simple_page_1.html")); |
| 1301 std::string script = "var iframe = document.createElement('iframe');" | 1295 std::string script = "var iframe = document.createElement('iframe');" |
| 1302 "iframe.src = '" + frame_url.spec() + "';" | 1296 "iframe.src = '" + frame_url.spec() + "';" |
| 1303 "document.body.appendChild(iframe);"; | 1297 "document.body.appendChild(iframe);"; |
| 1304 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1298 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1305 capturer.Wait(); | 1299 capturer.Wait(); |
| 1306 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1300 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1307 } | 1301 } |
| 1308 } | 1302 } |
| 1309 | 1303 |
| 1310 // Verify that navigations caused by client-side redirects are correctly | 1304 // Verify that navigations caused by client-side redirects are correctly |
| 1311 // classified. | 1305 // classified. |
| 1312 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1306 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1313 NavigationTypeClassification_ClientSideRedirect) { | 1307 NavigationTypeClassification_ClientSideRedirect) { |
| 1314 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 1308 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 1344 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 1351 | 1345 |
| 1352 FrameTreeNode* root = | 1346 FrameTreeNode* root = |
| 1353 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1347 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 1354 GetFrameTree()->root(); | 1348 GetFrameTree()->root(); |
| 1355 | 1349 |
| 1356 { | 1350 { |
| 1357 // Do a fragment link click. | 1351 // Do a fragment link click. |
| 1358 FrameNavigateParamsCapturer capturer(root); | 1352 FrameNavigateParamsCapturer capturer(root); |
| 1359 std::string script = "document.getElementById('fraglink').click()"; | 1353 std::string script = "document.getElementById('fraglink').click()"; |
| 1360 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1354 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1361 capturer.Wait(); | 1355 capturer.Wait(); |
| 1362 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); | 1356 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); |
| 1363 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 1357 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 1364 EXPECT_TRUE(capturer.details().is_in_page); | 1358 EXPECT_TRUE(capturer.details().is_in_page); |
| 1365 } | 1359 } |
| 1366 | 1360 |
| 1367 { | 1361 { |
| 1368 // Do a non-fragment link click. | 1362 // Do a non-fragment link click. |
| 1369 FrameNavigateParamsCapturer capturer(root); | 1363 FrameNavigateParamsCapturer capturer(root); |
| 1370 std::string script = "document.getElementById('thelink').click()"; | 1364 std::string script = "document.getElementById('thelink').click()"; |
| 1371 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1365 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1372 capturer.Wait(); | 1366 capturer.Wait(); |
| 1373 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); | 1367 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, capturer.params().transition); |
| 1374 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 1368 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 1375 EXPECT_FALSE(capturer.details().is_in_page); | 1369 EXPECT_FALSE(capturer.details().is_in_page); |
| 1376 } | 1370 } |
| 1377 | 1371 |
| 1378 // Second verse, same as the first. (But in a subframe.) | 1372 // Second verse, same as the first. (But in a subframe.) |
| 1379 | 1373 |
| 1380 GURL iframe_url(embedded_test_server()->GetURL( | 1374 GURL iframe_url(embedded_test_server()->GetURL( |
| 1381 "/navigation_controller/page_with_iframe.html")); | 1375 "/navigation_controller/page_with_iframe.html")); |
| 1382 NavigateToURL(shell(), iframe_url); | 1376 NavigateToURL(shell(), iframe_url); |
| 1383 | 1377 |
| 1384 root = static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1378 root = static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 1385 GetFrameTree()->root(); | 1379 GetFrameTree()->root(); |
| 1386 | 1380 |
| 1387 ASSERT_EQ(1U, root->child_count()); | 1381 ASSERT_EQ(1U, root->child_count()); |
| 1388 ASSERT_NE(nullptr, root->child_at(0)); | 1382 ASSERT_NE(nullptr, root->child_at(0)); |
| 1389 | 1383 |
| 1390 NavigateFrameToURL(root->child_at(0), links_url); | 1384 NavigateFrameToURL(root->child_at(0), links_url); |
| 1391 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 1385 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 1392 | 1386 |
| 1393 { | 1387 { |
| 1394 // Do a fragment link click. | 1388 // Do a fragment link click. |
| 1395 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1389 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 1396 std::string script = "document.getElementById('fraglink').click()"; | 1390 std::string script = "document.getElementById('fraglink').click()"; |
| 1397 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1391 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1398 capturer.Wait(); | 1392 capturer.Wait(); |
| 1399 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1393 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1400 capturer.params().transition); | 1394 capturer.params().transition); |
| 1401 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1395 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1402 EXPECT_TRUE(capturer.details().is_in_page); | 1396 EXPECT_TRUE(capturer.details().is_in_page); |
| 1403 } | 1397 } |
| 1404 | 1398 |
| 1405 { | 1399 { |
| 1406 // Do a non-fragment link click. | 1400 // Do a non-fragment link click. |
| 1407 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1401 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 1408 std::string script = "document.getElementById('thelink').click()"; | 1402 std::string script = "document.getElementById('thelink').click()"; |
| 1409 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1403 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1410 capturer.Wait(); | 1404 capturer.Wait(); |
| 1411 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 1405 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 1412 capturer.params().transition); | 1406 capturer.params().transition); |
| 1413 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 1407 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 1414 EXPECT_FALSE(capturer.details().is_in_page); | 1408 EXPECT_FALSE(capturer.details().is_in_page); |
| 1415 } | 1409 } |
| 1416 } | 1410 } |
| 1417 | 1411 |
| 1418 // Verify the tree of FrameNavigationEntries after initial about:blank commits | 1412 // Verify the tree of FrameNavigationEntries after initial about:blank commits |
| 1419 // in subframes, which should not count as real committed loads. | 1413 // in subframes, which should not count as real committed loads. |
| 1420 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1414 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1421 FrameNavigationEntry_BlankAutoSubframe) { | 1415 FrameNavigationEntry_BlankAutoSubframe) { |
| 1422 GURL about_blank_url(url::kAboutBlankURL); | 1416 GURL about_blank_url(url::kAboutBlankURL); |
| 1423 GURL main_url(embedded_test_server()->GetURL( | 1417 GURL main_url(embedded_test_server()->GetURL( |
| 1424 "/navigation_controller/simple_page_1.html")); | 1418 "/navigation_controller/simple_page_1.html")); |
| 1425 NavigateToURL(shell(), main_url); | 1419 NavigateToURL(shell(), main_url); |
| 1426 const NavigationControllerImpl& controller = | 1420 const NavigationControllerImpl& controller = |
| 1427 static_cast<const NavigationControllerImpl&>( | 1421 static_cast<const NavigationControllerImpl&>( |
| 1428 shell()->web_contents()->GetController()); | 1422 shell()->web_contents()->GetController()); |
| 1429 FrameTreeNode* root = | 1423 FrameTreeNode* root = |
| 1430 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1424 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 1431 GetFrameTree()->root(); | 1425 GetFrameTree()->root(); |
| 1432 | 1426 |
| 1433 // 1. Create a iframe with no URL. | 1427 // 1. Create a iframe with no URL. |
| 1434 { | 1428 { |
| 1435 LoadCommittedCapturer capturer(shell()->web_contents()); | 1429 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1436 std::string script = "var iframe = document.createElement('iframe');" | 1430 std::string script = "var iframe = document.createElement('iframe');" |
| 1437 "document.body.appendChild(iframe);"; | 1431 "document.body.appendChild(iframe);"; |
| 1438 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1432 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1439 capturer.Wait(); | 1433 capturer.Wait(); |
| 1440 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1434 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1441 } | 1435 } |
| 1442 | 1436 |
| 1443 // Check last committed NavigationEntry. | 1437 // Check last committed NavigationEntry. |
| 1444 EXPECT_EQ(1, controller.GetEntryCount()); | 1438 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1445 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 1439 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 1446 EXPECT_EQ(main_url, entry->GetURL()); | 1440 EXPECT_EQ(main_url, entry->GetURL()); |
| 1447 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 1441 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
| 1448 EXPECT_EQ(main_url, root_entry->url()); | 1442 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1460 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1454 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1461 } | 1455 } |
| 1462 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); | 1456 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); |
| 1463 | 1457 |
| 1464 // 1a. A nested iframe with no URL should also create a subframe entry but not | 1458 // 1a. A nested iframe with no URL should also create a subframe entry but not |
| 1465 // count as a real load. | 1459 // count as a real load. |
| 1466 { | 1460 { |
| 1467 LoadCommittedCapturer capturer(shell()->web_contents()); | 1461 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1468 std::string script = "var iframe = document.createElement('iframe');" | 1462 std::string script = "var iframe = document.createElement('iframe');" |
| 1469 "document.body.appendChild(iframe);"; | 1463 "document.body.appendChild(iframe);"; |
| 1470 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1464 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1471 capturer.Wait(); | 1465 capturer.Wait(); |
| 1472 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1466 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1473 } | 1467 } |
| 1474 | 1468 |
| 1475 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1469 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 1476 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1470 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1477 // The nested entry should have one blank subframe FrameNavigationEntry, but | 1471 // The nested entry should have one blank subframe FrameNavigationEntry, but |
| 1478 // this does not count as committing a real load. | 1472 // this does not count as committing a real load. |
| 1479 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | 1473 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
| 1480 FrameNavigationEntry* frame_entry = | 1474 FrameNavigationEntry* frame_entry = |
| 1481 entry->root_node()->children[0]->children[0]->frame_entry.get(); | 1475 entry->root_node()->children[0]->children[0]->frame_entry.get(); |
| 1482 EXPECT_EQ(about_blank_url, frame_entry->url()); | 1476 EXPECT_EQ(about_blank_url, frame_entry->url()); |
| 1483 } else { | 1477 } else { |
| 1484 // There are no subframe FrameNavigationEntries by default. | 1478 // There are no subframe FrameNavigationEntries by default. |
| 1485 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1479 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1486 } | 1480 } |
| 1487 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1481 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
| 1488 | 1482 |
| 1489 // 2. Create another iframe with an explicit about:blank URL. | 1483 // 2. Create another iframe with an explicit about:blank URL. |
| 1490 { | 1484 { |
| 1491 LoadCommittedCapturer capturer(shell()->web_contents()); | 1485 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1492 std::string script = "var iframe = document.createElement('iframe');" | 1486 std::string script = "var iframe = document.createElement('iframe');" |
| 1493 "iframe.src = 'about:blank';" | 1487 "iframe.src = 'about:blank';" |
| 1494 "document.body.appendChild(iframe);"; | 1488 "document.body.appendChild(iframe);"; |
| 1495 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1489 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1496 capturer.Wait(); | 1490 capturer.Wait(); |
| 1497 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1491 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1498 } | 1492 } |
| 1499 | 1493 |
| 1500 // Check last committed NavigationEntry. | 1494 // Check last committed NavigationEntry. |
| 1501 EXPECT_EQ(1, controller.GetEntryCount()); | 1495 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1502 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1496 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
| 1503 | 1497 |
| 1504 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1498 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 1505 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1499 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1506 // The new entry should have one blank subframe FrameNavigationEntry, but | 1500 // The new entry should have one blank subframe FrameNavigationEntry, but |
| 1507 // this does not count as committing a real load. | 1501 // this does not count as committing a real load. |
| 1508 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1502 ASSERT_EQ(2U, entry->root_node()->children.size()); |
| 1509 FrameNavigationEntry* frame_entry = | 1503 FrameNavigationEntry* frame_entry = |
| 1510 entry->root_node()->children[1]->frame_entry.get(); | 1504 entry->root_node()->children[1]->frame_entry.get(); |
| 1511 EXPECT_EQ(about_blank_url, frame_entry->url()); | 1505 EXPECT_EQ(about_blank_url, frame_entry->url()); |
| 1512 } else { | 1506 } else { |
| 1513 // There are no subframe FrameNavigationEntries by default. | 1507 // There are no subframe FrameNavigationEntries by default. |
| 1514 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1508 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1515 } | 1509 } |
| 1516 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); | 1510 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); |
| 1517 | 1511 |
| 1518 // 3. A real same-site navigation in the nested iframe should be AUTO. | 1512 // 3. A real same-site navigation in the nested iframe should be AUTO. |
| 1519 GURL frame_url(embedded_test_server()->GetURL( | 1513 GURL frame_url(embedded_test_server()->GetURL( |
| 1520 "/navigation_controller/simple_page_1.html")); | 1514 "/navigation_controller/simple_page_1.html")); |
| 1521 { | 1515 { |
| 1522 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); | 1516 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); |
| 1523 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1517 std::string script = "var frames = document.getElementsByTagName('iframe');" |
| 1524 "frames[0].src = '" + frame_url.spec() + "';"; | 1518 "frames[0].src = '" + frame_url.spec() + "';"; |
| 1525 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1519 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1526 capturer.Wait(); | 1520 capturer.Wait(); |
| 1527 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1521 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1528 } | 1522 } |
| 1529 | 1523 |
| 1530 // Check last committed NavigationEntry. It should have replaced the previous | 1524 // Check last committed NavigationEntry. It should have replaced the previous |
| 1531 // frame entry in the original NavigationEntry. | 1525 // frame entry in the original NavigationEntry. |
| 1532 EXPECT_EQ(1, controller.GetEntryCount()); | 1526 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1533 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1527 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
| 1534 | 1528 |
| 1535 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1529 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1547 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1541 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
| 1548 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); | 1542 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); |
| 1549 | 1543 |
| 1550 // 4. A real cross-site navigation in the second iframe should be AUTO. | 1544 // 4. A real cross-site navigation in the second iframe should be AUTO. |
| 1551 GURL foo_url(embedded_test_server()->GetURL( | 1545 GURL foo_url(embedded_test_server()->GetURL( |
| 1552 "foo.com", "/navigation_controller/simple_page_2.html")); | 1546 "foo.com", "/navigation_controller/simple_page_2.html")); |
| 1553 { | 1547 { |
| 1554 LoadCommittedCapturer capturer(root->child_at(1)); | 1548 LoadCommittedCapturer capturer(root->child_at(1)); |
| 1555 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1549 std::string script = "var frames = document.getElementsByTagName('iframe');" |
| 1556 "frames[1].src = '" + foo_url.spec() + "';"; | 1550 "frames[1].src = '" + foo_url.spec() + "';"; |
| 1557 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1551 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1558 capturer.Wait(); | 1552 capturer.Wait(); |
| 1559 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1553 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1560 } | 1554 } |
| 1561 | 1555 |
| 1562 // Check last committed NavigationEntry. | 1556 // Check last committed NavigationEntry. |
| 1563 EXPECT_EQ(1, controller.GetEntryCount()); | 1557 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1564 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1558 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
| 1565 | 1559 |
| 1566 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1560 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 1567 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1561 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1578 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1572 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
| 1579 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); | 1573 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); |
| 1580 | 1574 |
| 1581 // 5. A new navigation to about:blank in the nested frame should count as a | 1575 // 5. A new navigation to about:blank in the nested frame should count as a |
| 1582 // real load, since that frame has already committed a real load and this is | 1576 // real load, since that frame has already committed a real load and this is |
| 1583 // not the initial blank page. | 1577 // not the initial blank page. |
| 1584 { | 1578 { |
| 1585 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); | 1579 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); |
| 1586 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1580 std::string script = "var frames = document.getElementsByTagName('iframe');" |
| 1587 "frames[0].src = 'about:blank';"; | 1581 "frames[0].src = 'about:blank';"; |
| 1588 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1582 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1589 capturer.Wait(); | 1583 capturer.Wait(); |
| 1590 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, capturer.transition_type()); | 1584 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, capturer.transition_type()); |
| 1591 } | 1585 } |
| 1592 | 1586 |
| 1593 // This should have created a new NavigationEntry. | 1587 // This should have created a new NavigationEntry. |
| 1594 EXPECT_EQ(2, controller.GetEntryCount()); | 1588 EXPECT_EQ(2, controller.GetEntryCount()); |
| 1595 EXPECT_NE(entry, controller.GetLastCommittedEntry()); | 1589 EXPECT_NE(entry, controller.GetLastCommittedEntry()); |
| 1596 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 1590 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
| 1597 | 1591 |
| 1598 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1592 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 ->root(); | 1630 ->root(); |
| 1637 | 1631 |
| 1638 // 1. Create a iframe with a URL that doesn't commit. | 1632 // 1. Create a iframe with a URL that doesn't commit. |
| 1639 GURL slow_url(embedded_test_server()->GetURL( | 1633 GURL slow_url(embedded_test_server()->GetURL( |
| 1640 "/navigation_controller/simple_page_2.html")); | 1634 "/navigation_controller/simple_page_2.html")); |
| 1641 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); | 1635 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); |
| 1642 { | 1636 { |
| 1643 std::string script = "var iframe = document.createElement('iframe');" | 1637 std::string script = "var iframe = document.createElement('iframe');" |
| 1644 "iframe.src = '" + slow_url.spec() + "';" | 1638 "iframe.src = '" + slow_url.spec() + "';" |
| 1645 "document.body.appendChild(iframe);"; | 1639 "document.body.appendChild(iframe);"; |
| 1646 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1640 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1647 } | 1641 } |
| 1648 subframe_delayer.WaitForWillStartRequest(); | 1642 subframe_delayer.WaitForWillStartRequest(); |
| 1649 | 1643 |
| 1650 // Stop the request so that we can wait for load stop below, without ending up | 1644 // Stop the request so that we can wait for load stop below, without ending up |
| 1651 // with a commit for this frame. | 1645 // with a commit for this frame. |
| 1652 shell()->web_contents()->Stop(); | 1646 shell()->web_contents()->Stop(); |
| 1653 | 1647 |
| 1654 // 2. A nested iframe with a cross-site URL should be able to commit. | 1648 // 2. A nested iframe with a cross-site URL should be able to commit. |
| 1655 GURL foo_url(embedded_test_server()->GetURL( | 1649 GURL foo_url(embedded_test_server()->GetURL( |
| 1656 "foo.com", "/navigation_controller/simple_page_1.html")); | 1650 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1657 { | 1651 { |
| 1658 std::string script = "var iframe = document.createElement('iframe');" | 1652 std::string script = "var iframe = document.createElement('iframe');" |
| 1659 "iframe.src = '" + foo_url.spec() + "';" | 1653 "iframe.src = '" + foo_url.spec() + "';" |
| 1660 "document.body.appendChild(iframe);"; | 1654 "document.body.appendChild(iframe);"; |
| 1661 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1655 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1662 WaitForLoadStopWithoutSuccessCheck(shell()->web_contents()); | 1656 WaitForLoadStopWithoutSuccessCheck(shell()->web_contents()); |
| 1663 } | 1657 } |
| 1664 | 1658 |
| 1665 // TODO(creis): Check subframe entries once we create them in this case. | 1659 // TODO(creis): Check subframe entries once we create them in this case. |
| 1666 // See https://crbug.com/608402. | 1660 // See https://crbug.com/608402. |
| 1667 EXPECT_EQ(foo_url, root->child_at(0)->child_at(0)->current_url()); | 1661 EXPECT_EQ(foo_url, root->child_at(0)->child_at(0)->current_url()); |
| 1668 } | 1662 } |
| 1669 | 1663 |
| 1670 // Verify the tree of FrameNavigationEntries when a nested iframe commits inside | 1664 // Verify the tree of FrameNavigationEntries when a nested iframe commits inside |
| 1671 // the initial blank page of an iframe with no committed entry. Prevents | 1665 // the initial blank page of an iframe with no committed entry. Prevents |
| 1672 // regression of https://crbug.com/600743. | 1666 // regression of https://crbug.com/600743. |
| 1673 // Flaky test: See https://crbug.com/610801 | 1667 // Flaky test: See https://crbug.com/610801 |
| 1674 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1668 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1675 DISABLED_FrameNavigationEntry_NoCommitNestedAutoSubframe)
{ | 1669 DISABLED_FrameNavigationEntry_NoCommitNestedAutoSubframe)
{ |
| 1676 GURL main_url(embedded_test_server()->GetURL( | 1670 GURL main_url(embedded_test_server()->GetURL( |
| 1677 "/navigation_controller/simple_page_1.html")); | 1671 "/navigation_controller/simple_page_1.html")); |
| 1678 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1672 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1679 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1673 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1680 ->GetFrameTree() | 1674 ->GetFrameTree() |
| 1681 ->root(); | 1675 ->root(); |
| 1682 | 1676 |
| 1683 // 1. Create a iframe with a URL that doesn't commit. | 1677 // 1. Create a iframe with a URL that doesn't commit. |
| 1684 GURL no_commit_url(embedded_test_server()->GetURL("/nocontent")); | 1678 GURL no_commit_url(embedded_test_server()->GetURL("/nocontent")); |
| 1685 { | 1679 { |
| 1686 std::string script = "var iframe = document.createElement('iframe');" | 1680 std::string script = "var iframe = document.createElement('iframe');" |
| 1687 "iframe.src = '" + no_commit_url.spec() + "';" | 1681 "iframe.src = '" + no_commit_url.spec() + "';" |
| 1688 "document.body.appendChild(iframe);"; | 1682 "document.body.appendChild(iframe);"; |
| 1689 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1683 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1690 } | 1684 } |
| 1691 EXPECT_EQ(GURL(), root->child_at(0)->current_url()); | 1685 EXPECT_EQ(GURL(), root->child_at(0)->current_url()); |
| 1692 | 1686 |
| 1693 // 2. A nested iframe with a cross-site URL should be able to commit. | 1687 // 2. A nested iframe with a cross-site URL should be able to commit. |
| 1694 GURL foo_url(embedded_test_server()->GetURL( | 1688 GURL foo_url(embedded_test_server()->GetURL( |
| 1695 "foo.com", "/navigation_controller/simple_page_1.html")); | 1689 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1696 { | 1690 { |
| 1697 LoadCommittedCapturer capturer(shell()->web_contents()); | 1691 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1698 std::string script = "var iframe = document.createElement('iframe');" | 1692 std::string script = "var iframe = document.createElement('iframe');" |
| 1699 "iframe.src = '" + foo_url.spec() + "';" | 1693 "iframe.src = '" + foo_url.spec() + "';" |
| 1700 "document.body.appendChild(iframe);"; | 1694 "document.body.appendChild(iframe);"; |
| 1701 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1695 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1702 capturer.Wait(); | 1696 capturer.Wait(); |
| 1703 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1697 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1704 } | 1698 } |
| 1705 | 1699 |
| 1706 // TODO(creis): Check subframe entries once we create them in this case. | 1700 // TODO(creis): Check subframe entries once we create them in this case. |
| 1707 // See https://crbug.com/608402. | 1701 // See https://crbug.com/608402. |
| 1708 EXPECT_EQ(foo_url, root->child_at(0)->child_at(0)->current_url()); | 1702 EXPECT_EQ(foo_url, root->child_at(0)->child_at(0)->current_url()); |
| 1709 } | 1703 } |
| 1710 | 1704 |
| 1711 // Verify the tree of FrameNavigationEntries when a nested iframe commits after | 1705 // Verify the tree of FrameNavigationEntries when a nested iframe commits after |
| 1712 // going back in-page, in which case its parent might not have been in the | 1706 // going back in-page, in which case its parent might not have been in the |
| 1713 // NavigationEntry. Prevents regression of https://crbug.com/600743. | 1707 // NavigationEntry. Prevents regression of https://crbug.com/600743. |
| 1714 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1708 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1715 FrameNavigationEntry_BackNestedAutoSubframe) { | 1709 FrameNavigationEntry_BackNestedAutoSubframe) { |
| 1716 GURL main_url(embedded_test_server()->GetURL( | 1710 GURL main_url(embedded_test_server()->GetURL( |
| 1717 "/navigation_controller/simple_page_1.html")); | 1711 "/navigation_controller/simple_page_1.html")); |
| 1718 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1712 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1719 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1713 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1720 ->GetFrameTree() | 1714 ->GetFrameTree() |
| 1721 ->root(); | 1715 ->root(); |
| 1722 | 1716 |
| 1723 // 1. Navigate in-page. | 1717 // 1. Navigate in-page. |
| 1724 { | 1718 { |
| 1725 FrameNavigateParamsCapturer capturer(root); | 1719 FrameNavigateParamsCapturer capturer(root); |
| 1726 std::string script = "history.pushState({}, 'foo', 'foo')"; | 1720 std::string script = "history.pushState({}, 'foo', 'foo')"; |
| 1727 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1721 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1728 capturer.Wait(); | 1722 capturer.Wait(); |
| 1729 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 1723 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 1730 EXPECT_TRUE(capturer.details().is_in_page); | 1724 EXPECT_TRUE(capturer.details().is_in_page); |
| 1731 } | 1725 } |
| 1732 | 1726 |
| 1733 // 2. Create an iframe. | 1727 // 2. Create an iframe. |
| 1734 GURL child_url(embedded_test_server()->GetURL( | 1728 GURL child_url(embedded_test_server()->GetURL( |
| 1735 "/navigation_controller/simple_page_2.html")); | 1729 "/navigation_controller/simple_page_2.html")); |
| 1736 { | 1730 { |
| 1737 LoadCommittedCapturer capturer(shell()->web_contents()); | 1731 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1738 std::string script = "var iframe = document.createElement('iframe');" | 1732 std::string script = "var iframe = document.createElement('iframe');" |
| 1739 "iframe.src = '" + child_url.spec() + "';" | 1733 "iframe.src = '" + child_url.spec() + "';" |
| 1740 "document.body.appendChild(iframe);"; | 1734 "document.body.appendChild(iframe);"; |
| 1741 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1735 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1742 capturer.Wait(); | 1736 capturer.Wait(); |
| 1743 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1737 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1744 } | 1738 } |
| 1745 | 1739 |
| 1746 // 3. Go back in-page. | 1740 // 3. Go back in-page. |
| 1747 { | 1741 { |
| 1748 TestNavigationObserver back_load_observer(shell()->web_contents()); | 1742 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 1749 shell()->web_contents()->GetController().GoBack(); | 1743 shell()->web_contents()->GetController().GoBack(); |
| 1750 back_load_observer.Wait(); | 1744 back_load_observer.Wait(); |
| 1751 } | 1745 } |
| 1752 | 1746 |
| 1753 // 4. A nested iframe with a cross-site URL should be able to commit. | 1747 // 4. A nested iframe with a cross-site URL should be able to commit. |
| 1754 GURL grandchild_url(embedded_test_server()->GetURL( | 1748 GURL grandchild_url(embedded_test_server()->GetURL( |
| 1755 "foo.com", "/navigation_controller/simple_page_1.html")); | 1749 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1756 { | 1750 { |
| 1757 LoadCommittedCapturer capturer(shell()->web_contents()); | 1751 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1758 std::string script = "var iframe = document.createElement('iframe');" | 1752 std::string script = "var iframe = document.createElement('iframe');" |
| 1759 "iframe.src = '" + grandchild_url.spec() + "';" | 1753 "iframe.src = '" + grandchild_url.spec() + "';" |
| 1760 "document.body.appendChild(iframe);"; | 1754 "document.body.appendChild(iframe);"; |
| 1761 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1755 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1762 capturer.Wait(); | 1756 capturer.Wait(); |
| 1763 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1757 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1764 } | 1758 } |
| 1765 | 1759 |
| 1766 // TODO(creis): Check subframe entries once we create them in this case. | 1760 // TODO(creis): Check subframe entries once we create them in this case. |
| 1767 // See https://crbug.com/608402. | 1761 // See https://crbug.com/608402. |
| 1768 EXPECT_EQ(grandchild_url, root->child_at(0)->child_at(0)->current_url()); | 1762 EXPECT_EQ(grandchild_url, root->child_at(0)->child_at(0)->current_url()); |
| 1769 } | 1763 } |
| 1770 | 1764 |
| 1771 // Verify the tree of FrameNavigationEntries when a nested iframe commits after | 1765 // Verify the tree of FrameNavigationEntries when a nested iframe commits after |
| 1772 // its parent changes its name, in which case we might not find the parent | 1766 // its parent changes its name, in which case we might not find the parent |
| 1773 // FrameNavigationEntry. Prevents regression of https://crbug.com/600743. | 1767 // FrameNavigationEntry. Prevents regression of https://crbug.com/600743. |
| 1774 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1768 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1775 FrameNavigationEntry_RenameNestedAutoSubframe) { | 1769 FrameNavigationEntry_RenameNestedAutoSubframe) { |
| 1776 GURL main_url(embedded_test_server()->GetURL( | 1770 GURL main_url(embedded_test_server()->GetURL( |
| 1777 "/navigation_controller/simple_page_1.html")); | 1771 "/navigation_controller/simple_page_1.html")); |
| 1778 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1772 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1779 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1773 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1780 ->GetFrameTree() | 1774 ->GetFrameTree() |
| 1781 ->root(); | 1775 ->root(); |
| 1782 | 1776 |
| 1783 // 1. Create an iframe. | 1777 // 1. Create an iframe. |
| 1784 GURL child_url(embedded_test_server()->GetURL( | 1778 GURL child_url(embedded_test_server()->GetURL( |
| 1785 "/navigation_controller/simple_page_2.html")); | 1779 "/navigation_controller/simple_page_2.html")); |
| 1786 { | 1780 { |
| 1787 LoadCommittedCapturer capturer(shell()->web_contents()); | 1781 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1788 std::string script = "var iframe = document.createElement('iframe');" | 1782 std::string script = "var iframe = document.createElement('iframe');" |
| 1789 "iframe.src = '" + child_url.spec() + "';" | 1783 "iframe.src = '" + child_url.spec() + "';" |
| 1790 "document.body.appendChild(iframe);"; | 1784 "document.body.appendChild(iframe);"; |
| 1791 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1785 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1792 capturer.Wait(); | 1786 capturer.Wait(); |
| 1793 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1787 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1794 } | 1788 } |
| 1795 | 1789 |
| 1796 // 2. Change the iframe's name. | 1790 // 2. Change the iframe's name. |
| 1797 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), | 1791 EXPECT_TRUE(ExecuteScript(root->child_at(0), "window.name = 'foo';")); |
| 1798 "window.name = 'foo';")); | |
| 1799 | 1792 |
| 1800 // 3. A nested iframe with a cross-site URL should be able to commit. | 1793 // 3. A nested iframe with a cross-site URL should be able to commit. |
| 1801 GURL bar_url(embedded_test_server()->GetURL( | 1794 GURL bar_url(embedded_test_server()->GetURL( |
| 1802 "bar.com", "/navigation_controller/simple_page_1.html")); | 1795 "bar.com", "/navigation_controller/simple_page_1.html")); |
| 1803 { | 1796 { |
| 1804 LoadCommittedCapturer capturer(shell()->web_contents()); | 1797 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1805 std::string script = "var iframe = document.createElement('iframe');" | 1798 std::string script = "var iframe = document.createElement('iframe');" |
| 1806 "iframe.src = '" + bar_url.spec() + "';" | 1799 "iframe.src = '" + bar_url.spec() + "';" |
| 1807 "document.body.appendChild(iframe);"; | 1800 "document.body.appendChild(iframe);"; |
| 1808 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 1801 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 1809 | 1802 |
| 1810 capturer.Wait(); | 1803 capturer.Wait(); |
| 1811 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1804 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1812 } | 1805 } |
| 1813 | 1806 |
| 1814 // TODO(creis): Check subframe entries once we create them in this case. | 1807 // TODO(creis): Check subframe entries once we create them in this case. |
| 1815 // See https://crbug.com/608402. | 1808 // See https://crbug.com/608402. |
| 1816 EXPECT_EQ(bar_url, root->child_at(0)->child_at(0)->current_url()); | 1809 EXPECT_EQ(bar_url, root->child_at(0)->child_at(0)->current_url()); |
| 1817 } | 1810 } |
| 1818 | 1811 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1832 GetFrameTree()->root(); | 1825 GetFrameTree()->root(); |
| 1833 | 1826 |
| 1834 // 1. Create a same-site iframe. | 1827 // 1. Create a same-site iframe. |
| 1835 GURL frame_url(embedded_test_server()->GetURL( | 1828 GURL frame_url(embedded_test_server()->GetURL( |
| 1836 "/navigation_controller/simple_page_2.html")); | 1829 "/navigation_controller/simple_page_2.html")); |
| 1837 { | 1830 { |
| 1838 LoadCommittedCapturer capturer(shell()->web_contents()); | 1831 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1839 std::string script = "var iframe = document.createElement('iframe');" | 1832 std::string script = "var iframe = document.createElement('iframe');" |
| 1840 "iframe.src = '" + frame_url.spec() + "';" | 1833 "iframe.src = '" + frame_url.spec() + "';" |
| 1841 "document.body.appendChild(iframe);"; | 1834 "document.body.appendChild(iframe);"; |
| 1842 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1835 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1843 capturer.Wait(); | 1836 capturer.Wait(); |
| 1844 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1837 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1845 } | 1838 } |
| 1846 | 1839 |
| 1847 // Check last committed NavigationEntry. | 1840 // Check last committed NavigationEntry. |
| 1848 EXPECT_EQ(1, controller.GetEntryCount()); | 1841 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1849 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 1842 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 1850 EXPECT_EQ(main_url, entry->GetURL()); | 1843 EXPECT_EQ(main_url, entry->GetURL()); |
| 1851 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 1844 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
| 1852 EXPECT_EQ(main_url, root_entry->url()); | 1845 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1866 } | 1859 } |
| 1867 | 1860 |
| 1868 // 2. Create a second, initially cross-site iframe. | 1861 // 2. Create a second, initially cross-site iframe. |
| 1869 GURL foo_url(embedded_test_server()->GetURL( | 1862 GURL foo_url(embedded_test_server()->GetURL( |
| 1870 "foo.com", "/navigation_controller/simple_page_1.html")); | 1863 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1871 { | 1864 { |
| 1872 LoadCommittedCapturer capturer(shell()->web_contents()); | 1865 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1873 std::string script = "var iframe = document.createElement('iframe');" | 1866 std::string script = "var iframe = document.createElement('iframe');" |
| 1874 "iframe.src = '" + foo_url.spec() + "';" | 1867 "iframe.src = '" + foo_url.spec() + "';" |
| 1875 "document.body.appendChild(iframe);"; | 1868 "document.body.appendChild(iframe);"; |
| 1876 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1869 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1877 capturer.Wait(); | 1870 capturer.Wait(); |
| 1878 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1871 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1879 } | 1872 } |
| 1880 | 1873 |
| 1881 // The last committed NavigationEntry shouldn't have changed. | 1874 // The last committed NavigationEntry shouldn't have changed. |
| 1882 EXPECT_EQ(1, controller.GetEntryCount()); | 1875 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1883 entry = controller.GetLastCommittedEntry(); | 1876 entry = controller.GetLastCommittedEntry(); |
| 1884 EXPECT_EQ(main_url, entry->GetURL()); | 1877 EXPECT_EQ(main_url, entry->GetURL()); |
| 1885 root_entry = entry->root_node()->frame_entry.get(); | 1878 root_entry = entry->root_node()->frame_entry.get(); |
| 1886 EXPECT_EQ(main_url, root_entry->url()); | 1879 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1898 // There are no subframe FrameNavigationEntries by default. | 1891 // There are no subframe FrameNavigationEntries by default. |
| 1899 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1892 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1900 } | 1893 } |
| 1901 | 1894 |
| 1902 // 3. Create a nested iframe in the second subframe. | 1895 // 3. Create a nested iframe in the second subframe. |
| 1903 { | 1896 { |
| 1904 LoadCommittedCapturer capturer(shell()->web_contents()); | 1897 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1905 std::string script = "var iframe = document.createElement('iframe');" | 1898 std::string script = "var iframe = document.createElement('iframe');" |
| 1906 "iframe.src = '" + foo_url.spec() + "';" | 1899 "iframe.src = '" + foo_url.spec() + "';" |
| 1907 "document.body.appendChild(iframe);"; | 1900 "document.body.appendChild(iframe);"; |
| 1908 EXPECT_TRUE(ExecuteScript(root->child_at(1)->current_frame_host(), script)); | 1901 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); |
| 1909 capturer.Wait(); | 1902 capturer.Wait(); |
| 1910 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1903 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1911 } | 1904 } |
| 1912 | 1905 |
| 1913 // The last committed NavigationEntry shouldn't have changed. | 1906 // The last committed NavigationEntry shouldn't have changed. |
| 1914 EXPECT_EQ(1, controller.GetEntryCount()); | 1907 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1915 entry = controller.GetLastCommittedEntry(); | 1908 entry = controller.GetLastCommittedEntry(); |
| 1916 EXPECT_EQ(main_url, entry->GetURL()); | 1909 EXPECT_EQ(main_url, entry->GetURL()); |
| 1917 root_entry = entry->root_node()->frame_entry.get(); | 1910 root_entry = entry->root_node()->frame_entry.get(); |
| 1918 EXPECT_EQ(main_url, root_entry->url()); | 1911 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1930 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1923 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1931 } | 1924 } |
| 1932 | 1925 |
| 1933 // 4. Create a third iframe on the same site as the second. This ensures that | 1926 // 4. Create a third iframe on the same site as the second. This ensures that |
| 1934 // the commit type is correct even when the subframe process already exists. | 1927 // the commit type is correct even when the subframe process already exists. |
| 1935 { | 1928 { |
| 1936 LoadCommittedCapturer capturer(shell()->web_contents()); | 1929 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1937 std::string script = "var iframe = document.createElement('iframe');" | 1930 std::string script = "var iframe = document.createElement('iframe');" |
| 1938 "iframe.src = '" + foo_url.spec() + "';" | 1931 "iframe.src = '" + foo_url.spec() + "';" |
| 1939 "document.body.appendChild(iframe);"; | 1932 "document.body.appendChild(iframe);"; |
| 1940 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 1933 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1941 capturer.Wait(); | 1934 capturer.Wait(); |
| 1942 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1935 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1943 } | 1936 } |
| 1944 | 1937 |
| 1945 // The last committed NavigationEntry shouldn't have changed. | 1938 // The last committed NavigationEntry shouldn't have changed. |
| 1946 EXPECT_EQ(1, controller.GetEntryCount()); | 1939 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1947 entry = controller.GetLastCommittedEntry(); | 1940 entry = controller.GetLastCommittedEntry(); |
| 1948 EXPECT_EQ(main_url, entry->GetURL()); | 1941 EXPECT_EQ(main_url, entry->GetURL()); |
| 1949 root_entry = entry->root_node()->frame_entry.get(); | 1942 root_entry = entry->root_node()->frame_entry.get(); |
| 1950 EXPECT_EQ(main_url, root_entry->url()); | 1943 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1961 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1954 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1962 } | 1955 } |
| 1963 | 1956 |
| 1964 // 5. Create a nested iframe on the original site (A-B-A). | 1957 // 5. Create a nested iframe on the original site (A-B-A). |
| 1965 { | 1958 { |
| 1966 LoadCommittedCapturer capturer(shell()->web_contents()); | 1959 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1967 std::string script = "var iframe = document.createElement('iframe');" | 1960 std::string script = "var iframe = document.createElement('iframe');" |
| 1968 "iframe.src = '" + frame_url.spec() + "';" | 1961 "iframe.src = '" + frame_url.spec() + "';" |
| 1969 "document.body.appendChild(iframe);"; | 1962 "document.body.appendChild(iframe);"; |
| 1970 FrameTreeNode* child = root->child_at(2); | 1963 FrameTreeNode* child = root->child_at(2); |
| 1971 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), script)); | 1964 EXPECT_TRUE(ExecuteScript(child, script)); |
| 1972 capturer.Wait(); | 1965 capturer.Wait(); |
| 1973 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1966 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1974 } | 1967 } |
| 1975 | 1968 |
| 1976 // The last committed NavigationEntry shouldn't have changed. | 1969 // The last committed NavigationEntry shouldn't have changed. |
| 1977 EXPECT_EQ(1, controller.GetEntryCount()); | 1970 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1978 entry = controller.GetLastCommittedEntry(); | 1971 entry = controller.GetLastCommittedEntry(); |
| 1979 EXPECT_EQ(main_url, entry->GetURL()); | 1972 EXPECT_EQ(main_url, entry->GetURL()); |
| 1980 root_entry = entry->root_node()->frame_entry.get(); | 1973 root_entry = entry->root_node()->frame_entry.get(); |
| 1981 EXPECT_EQ(main_url, root_entry->url()); | 1974 EXPECT_EQ(main_url, root_entry->url()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 GetFrameTree()->root(); | 2016 GetFrameTree()->root(); |
| 2024 | 2017 |
| 2025 // 1. Create a same-site iframe. | 2018 // 1. Create a same-site iframe. |
| 2026 GURL frame_url(embedded_test_server()->GetURL( | 2019 GURL frame_url(embedded_test_server()->GetURL( |
| 2027 "/navigation_controller/simple_page_2.html")); | 2020 "/navigation_controller/simple_page_2.html")); |
| 2028 { | 2021 { |
| 2029 LoadCommittedCapturer capturer(shell()->web_contents()); | 2022 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2030 std::string script = "var iframe = document.createElement('iframe');" | 2023 std::string script = "var iframe = document.createElement('iframe');" |
| 2031 "iframe.src = '" + frame_url.spec() + "';" | 2024 "iframe.src = '" + frame_url.spec() + "';" |
| 2032 "document.body.appendChild(iframe);"; | 2025 "document.body.appendChild(iframe);"; |
| 2033 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2026 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2034 capturer.Wait(); | 2027 capturer.Wait(); |
| 2035 } | 2028 } |
| 2036 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2029 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 2037 | 2030 |
| 2038 // 2. Navigate in the subframe same-site. | 2031 // 2. Navigate in the subframe same-site. |
| 2039 GURL frame_url2(embedded_test_server()->GetURL( | 2032 GURL frame_url2(embedded_test_server()->GetURL( |
| 2040 "/navigation_controller/page_with_links.html")); | 2033 "/navigation_controller/page_with_links.html")); |
| 2041 { | 2034 { |
| 2042 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2035 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 2043 NavigateFrameToURL(root->child_at(0), frame_url2); | 2036 NavigateFrameToURL(root->child_at(0), frame_url2); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2067 } | 2060 } |
| 2068 | 2061 |
| 2069 // 3. Create a second, initially cross-site iframe. | 2062 // 3. Create a second, initially cross-site iframe. |
| 2070 GURL foo_url(embedded_test_server()->GetURL( | 2063 GURL foo_url(embedded_test_server()->GetURL( |
| 2071 "foo.com", "/navigation_controller/simple_page_1.html")); | 2064 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 2072 { | 2065 { |
| 2073 LoadCommittedCapturer capturer(shell()->web_contents()); | 2066 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2074 std::string script = "var iframe = document.createElement('iframe');" | 2067 std::string script = "var iframe = document.createElement('iframe');" |
| 2075 "iframe.src = '" + foo_url.spec() + "';" | 2068 "iframe.src = '" + foo_url.spec() + "';" |
| 2076 "document.body.appendChild(iframe);"; | 2069 "document.body.appendChild(iframe);"; |
| 2077 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2070 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2078 capturer.Wait(); | 2071 capturer.Wait(); |
| 2079 } | 2072 } |
| 2080 | 2073 |
| 2081 // 4. Create a nested same-site iframe in the second subframe, wait for it to | 2074 // 4. Create a nested same-site iframe in the second subframe, wait for it to |
| 2082 // commit, then navigate it again. | 2075 // commit, then navigate it again. |
| 2083 { | 2076 { |
| 2084 LoadCommittedCapturer capturer(shell()->web_contents()); | 2077 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2085 std::string script = "var iframe = document.createElement('iframe');" | 2078 std::string script = "var iframe = document.createElement('iframe');" |
| 2086 "iframe.src = '" + foo_url.spec() + "';" | 2079 "iframe.src = '" + foo_url.spec() + "';" |
| 2087 "document.body.appendChild(iframe);"; | 2080 "document.body.appendChild(iframe);"; |
| 2088 EXPECT_TRUE(ExecuteScript(root->child_at(1)->current_frame_host(), script)); | 2081 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); |
| 2089 capturer.Wait(); | 2082 capturer.Wait(); |
| 2090 } | 2083 } |
| 2091 GURL bar_url(embedded_test_server()->GetURL( | 2084 GURL bar_url(embedded_test_server()->GetURL( |
| 2092 "bar.com", "/navigation_controller/simple_page_1.html")); | 2085 "bar.com", "/navigation_controller/simple_page_1.html")); |
| 2093 { | 2086 { |
| 2094 FrameNavigateParamsCapturer capturer(root->child_at(1)->child_at(0)); | 2087 FrameNavigateParamsCapturer capturer(root->child_at(1)->child_at(0)); |
| 2095 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); | 2088 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); |
| 2096 capturer.Wait(); | 2089 capturer.Wait(); |
| 2097 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 2090 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 2098 capturer.params().transition); | 2091 capturer.params().transition); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2123 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2116 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2124 } | 2117 } |
| 2125 | 2118 |
| 2126 // 6. Navigate the second subframe cross-site, clearing its existing subtree. | 2119 // 6. Navigate the second subframe cross-site, clearing its existing subtree. |
| 2127 GURL baz_url(embedded_test_server()->GetURL( | 2120 GURL baz_url(embedded_test_server()->GetURL( |
| 2128 "baz.com", "/navigation_controller/simple_page_1.html")); | 2121 "baz.com", "/navigation_controller/simple_page_1.html")); |
| 2129 { | 2122 { |
| 2130 FrameNavigateParamsCapturer capturer(root->child_at(1)); | 2123 FrameNavigateParamsCapturer capturer(root->child_at(1)); |
| 2131 std::string script = "var frames = document.getElementsByTagName('iframe');" | 2124 std::string script = "var frames = document.getElementsByTagName('iframe');" |
| 2132 "frames[1].src = '" + baz_url.spec() + "';"; | 2125 "frames[1].src = '" + baz_url.spec() + "';"; |
| 2133 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2126 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2134 capturer.Wait(); | 2127 capturer.Wait(); |
| 2135 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | 2128 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, |
| 2136 capturer.params().transition); | 2129 capturer.params().transition); |
| 2137 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 2130 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 2138 } | 2131 } |
| 2139 | 2132 |
| 2140 // We should have created a new NavigationEntry with the same main frame URL. | 2133 // We should have created a new NavigationEntry with the same main frame URL. |
| 2141 EXPECT_EQ(4, controller.GetEntryCount()); | 2134 EXPECT_EQ(4, controller.GetEntryCount()); |
| 2142 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2135 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2143 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); | 2136 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 "/navigation_controller/simple_page_1.html")); | 2185 "/navigation_controller/simple_page_1.html")); |
| 2193 { | 2186 { |
| 2194 LoadCommittedCapturer capturer(root->child_at(0)); | 2187 LoadCommittedCapturer capturer(root->child_at(0)); |
| 2195 NavigateFrameToURL(root->child_at(0), subframe_url); | 2188 NavigateFrameToURL(root->child_at(0), subframe_url); |
| 2196 capturer.Wait(); | 2189 capturer.Wait(); |
| 2197 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 2190 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 2198 } | 2191 } |
| 2199 | 2192 |
| 2200 // 2. In-page navigation in the main frame. | 2193 // 2. In-page navigation in the main frame. |
| 2201 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; | 2194 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; |
| 2202 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), push_script)); | 2195 EXPECT_TRUE(ExecuteScript(root, push_script)); |
| 2203 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 2196 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 2204 | 2197 |
| 2205 // TODO(creis): Verify subframe entries. https://crbug.com/522193. | 2198 // TODO(creis): Verify subframe entries. https://crbug.com/522193. |
| 2206 | 2199 |
| 2207 // 3. Add a nested subframe. | 2200 // 3. Add a nested subframe. |
| 2208 { | 2201 { |
| 2209 LoadCommittedCapturer capturer(shell()->web_contents()); | 2202 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2210 std::string script = "var iframe = document.createElement('iframe');" | 2203 std::string script = "var iframe = document.createElement('iframe');" |
| 2211 "iframe.src = '" + subframe_url.spec() + "';" | 2204 "iframe.src = '" + subframe_url.spec() + "';" |
| 2212 "document.body.appendChild(iframe);"; | 2205 "document.body.appendChild(iframe);"; |
| 2213 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 2206 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
| 2214 capturer.Wait(); | 2207 capturer.Wait(); |
| 2215 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 2208 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 2216 } | 2209 } |
| 2217 | 2210 |
| 2218 // TODO(creis): Verify subframe entries. https://crbug.com/522193. | 2211 // TODO(creis): Verify subframe entries. https://crbug.com/522193. |
| 2219 } | 2212 } |
| 2220 | 2213 |
| 2221 // Verify the tree of FrameNavigationEntries after back/forward navigations in a | 2214 // Verify the tree of FrameNavigationEntries after back/forward navigations in a |
| 2222 // cross-site subframe. | 2215 // cross-site subframe. |
| 2223 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2216 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 2224 FrameNavigationEntry_SubframeBackForward) { | 2217 FrameNavigationEntry_SubframeBackForward) { |
| 2225 GURL main_url(embedded_test_server()->GetURL( | 2218 GURL main_url(embedded_test_server()->GetURL( |
| 2226 "/navigation_controller/simple_page_1.html")); | 2219 "/navigation_controller/simple_page_1.html")); |
| 2227 NavigateToURL(shell(), main_url); | 2220 NavigateToURL(shell(), main_url); |
| 2228 const NavigationControllerImpl& controller = | 2221 const NavigationControllerImpl& controller = |
| 2229 static_cast<const NavigationControllerImpl&>( | 2222 static_cast<const NavigationControllerImpl&>( |
| 2230 shell()->web_contents()->GetController()); | 2223 shell()->web_contents()->GetController()); |
| 2231 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2224 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 2232 ->GetFrameTree() | 2225 ->GetFrameTree() |
| 2233 ->root(); | 2226 ->root(); |
| 2234 | 2227 |
| 2235 // 1. Create a same-site iframe. | 2228 // 1. Create a same-site iframe. |
| 2236 GURL frame_url(embedded_test_server()->GetURL( | 2229 GURL frame_url(embedded_test_server()->GetURL( |
| 2237 "/navigation_controller/simple_page_2.html")); | 2230 "/navigation_controller/simple_page_2.html")); |
| 2238 { | 2231 { |
| 2239 LoadCommittedCapturer capturer(shell()->web_contents()); | 2232 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2240 std::string script = "var iframe = document.createElement('iframe');" | 2233 std::string script = "var iframe = document.createElement('iframe');" |
| 2241 "iframe.src = '" + frame_url.spec() + "';" | 2234 "iframe.src = '" + frame_url.spec() + "';" |
| 2242 "document.body.appendChild(iframe);"; | 2235 "document.body.appendChild(iframe);"; |
| 2243 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2236 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2244 capturer.Wait(); | 2237 capturer.Wait(); |
| 2245 } | 2238 } |
| 2246 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); | 2239 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); |
| 2247 | 2240 |
| 2248 // 2. Navigate in the subframe cross-site. | 2241 // 2. Navigate in the subframe cross-site. |
| 2249 GURL frame_url2(embedded_test_server()->GetURL( | 2242 GURL frame_url2(embedded_test_server()->GetURL( |
| 2250 "foo.com", "/navigation_controller/page_with_links.html")); | 2243 "foo.com", "/navigation_controller/page_with_links.html")); |
| 2251 { | 2244 { |
| 2252 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2245 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 2253 NavigateFrameToURL(root->child_at(0), frame_url2); | 2246 NavigateFrameToURL(root->child_at(0), frame_url2); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 entry4->root_node()->children[0]->frame_entry->url()); | 2499 entry4->root_node()->children[0]->frame_entry->url()); |
| 2507 EXPECT_EQ( | 2500 EXPECT_EQ( |
| 2508 frame_url_c, | 2501 frame_url_c, |
| 2509 entry4->root_node()->children[0]->children[0]->frame_entry->url()); | 2502 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2510 } else { | 2503 } else { |
| 2511 // There are no subframe FrameNavigationEntries by default. | 2504 // There are no subframe FrameNavigationEntries by default. |
| 2512 EXPECT_EQ(0U, entry4->root_node()->children.size()); | 2505 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
| 2513 } | 2506 } |
| 2514 | 2507 |
| 2515 // Inject a JS value so that we can check for it later. | 2508 // Inject a JS value so that we can check for it later. |
| 2516 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), "foo=3;")); | 2509 EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); |
| 2517 | 2510 |
| 2518 // 7. Go back again, to the data URL in the nested iframe. | 2511 // 7. Go back again, to the data URL in the nested iframe. |
| 2519 { | 2512 { |
| 2520 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2513 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2521 shell()->web_contents()->GetController().GoBack(); | 2514 shell()->web_contents()->GetController().GoBack(); |
| 2522 back_load_observer.Wait(); | 2515 back_load_observer.Wait(); |
| 2523 } | 2516 } |
| 2524 ASSERT_EQ(1U, root->child_count()); | 2517 ASSERT_EQ(1U, root->child_count()); |
| 2525 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 2518 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
| 2526 EXPECT_EQ(main_url_a, root->current_url()); | 2519 EXPECT_EQ(main_url_a, root->current_url()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2542 data_url, | 2535 data_url, |
| 2543 entry3->root_node()->children[0]->children[0]->frame_entry->url()); | 2536 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2544 } else { | 2537 } else { |
| 2545 // There are no subframe FrameNavigationEntries by default. | 2538 // There are no subframe FrameNavigationEntries by default. |
| 2546 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2539 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2547 } | 2540 } |
| 2548 | 2541 |
| 2549 // Verify that we did not reload the main frame. See https://crbug.com/586234. | 2542 // Verify that we did not reload the main frame. See https://crbug.com/586234. |
| 2550 { | 2543 { |
| 2551 int value = 0; | 2544 int value = 0; |
| 2552 EXPECT_TRUE(ExecuteScriptAndExtractInt(root->current_frame_host(), | 2545 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 2553 "domAutomationController.send(foo)", | 2546 root, "domAutomationController.send(foo)", &value)); |
| 2554 &value)); | |
| 2555 EXPECT_EQ(3, value); | 2547 EXPECT_EQ(3, value); |
| 2556 } | 2548 } |
| 2557 | 2549 |
| 2558 // 8. Go back again, to the data URL in the first subframe. | 2550 // 8. Go back again, to the data URL in the first subframe. |
| 2559 { | 2551 { |
| 2560 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2552 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2561 shell()->web_contents()->GetController().GoBack(); | 2553 shell()->web_contents()->GetController().GoBack(); |
| 2562 back_load_observer.Wait(); | 2554 back_load_observer.Wait(); |
| 2563 } | 2555 } |
| 2564 ASSERT_EQ(1U, root->child_count()); | 2556 ASSERT_EQ(1U, root->child_count()); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 // Test subframe unique names only if enabled, e.g. in --site-per-process. | 2871 // Test subframe unique names only if enabled, e.g. in --site-per-process. |
| 2880 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2872 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 2881 return; | 2873 return; |
| 2882 | 2874 |
| 2883 // 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation. | 2875 // 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation. |
| 2884 { | 2876 { |
| 2885 LoadCommittedCapturer capturer(shell()->web_contents()); | 2877 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2886 std::string script = "var iframe = document.createElement('iframe');" | 2878 std::string script = "var iframe = document.createElement('iframe');" |
| 2887 "iframe.src = '" + url.spec() + "';" | 2879 "iframe.src = '" + url.spec() + "';" |
| 2888 "document.body.appendChild(iframe);"; | 2880 "document.body.appendChild(iframe);"; |
| 2889 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2881 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2890 capturer.Wait(); | 2882 capturer.Wait(); |
| 2891 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 2883 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 2892 } | 2884 } |
| 2893 | 2885 |
| 2894 // The root FrameNavigationEntry hasn't changed. | 2886 // The root FrameNavigationEntry hasn't changed. |
| 2895 EXPECT_EQ(frame_entry, | 2887 EXPECT_EQ(frame_entry, |
| 2896 controller.GetLastCommittedEntry()->GetFrameEntry(root)); | 2888 controller.GetLastCommittedEntry()->GetFrameEntry(root)); |
| 2897 | 2889 |
| 2898 // The subframe should have a generated name. | 2890 // The subframe should have a generated name. |
| 2899 FrameTreeNode* subframe = root->child_at(0); | 2891 FrameTreeNode* subframe = root->child_at(0); |
| 2900 EXPECT_EQ(main_site_instance, | 2892 EXPECT_EQ(main_site_instance, |
| 2901 subframe->current_frame_host()->GetSiteInstance()); | 2893 subframe->current_frame_host()->GetSiteInstance()); |
| 2902 FrameNavigationEntry* subframe_entry = | 2894 FrameNavigationEntry* subframe_entry = |
| 2903 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 2895 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
| 2904 std::string unnamed_subframe_name = "<!--framePath //<!--frame0-->-->"; | 2896 std::string unnamed_subframe_name = "<!--framePath //<!--frame0-->-->"; |
| 2905 EXPECT_EQ(unnamed_subframe_name, subframe_entry->frame_unique_name()); | 2897 EXPECT_EQ(unnamed_subframe_name, subframe_entry->frame_unique_name()); |
| 2906 | 2898 |
| 2907 // 3. Add a named subframe. | 2899 // 3. Add a named subframe. |
| 2908 { | 2900 { |
| 2909 LoadCommittedCapturer capturer(shell()->web_contents()); | 2901 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2910 std::string script = "var iframe = document.createElement('iframe');" | 2902 std::string script = "var iframe = document.createElement('iframe');" |
| 2911 "iframe.src = '" + url.spec() + "';" | 2903 "iframe.src = '" + url.spec() + "';" |
| 2912 "iframe.name = 'foo';" | 2904 "iframe.name = 'foo';" |
| 2913 "document.body.appendChild(iframe);"; | 2905 "document.body.appendChild(iframe);"; |
| 2914 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 2906 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2915 capturer.Wait(); | 2907 capturer.Wait(); |
| 2916 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 2908 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 2917 } | 2909 } |
| 2918 | 2910 |
| 2919 // The new subframe should have the specified name. | 2911 // The new subframe should have the specified name. |
| 2920 EXPECT_EQ(frame_entry, | 2912 EXPECT_EQ(frame_entry, |
| 2921 controller.GetLastCommittedEntry()->GetFrameEntry(root)); | 2913 controller.GetLastCommittedEntry()->GetFrameEntry(root)); |
| 2922 FrameTreeNode* foo_subframe = root->child_at(1); | 2914 FrameTreeNode* foo_subframe = root->child_at(1); |
| 2923 EXPECT_EQ(main_site_instance, | 2915 EXPECT_EQ(main_site_instance, |
| 2924 foo_subframe->current_frame_host()->GetSiteInstance()); | 2916 foo_subframe->current_frame_host()->GetSiteInstance()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2953 // Ensure we don't crash when cloning a named window. This happened in | 2945 // Ensure we don't crash when cloning a named window. This happened in |
| 2954 // https://crbug.com/603245 because neither the FrameTreeNode ID nor the name of | 2946 // https://crbug.com/603245 because neither the FrameTreeNode ID nor the name of |
| 2955 // the cloned window matched the root FrameNavigationEntry. | 2947 // the cloned window matched the root FrameNavigationEntry. |
| 2956 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, CloneNamedWindow) { | 2948 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, CloneNamedWindow) { |
| 2957 // Start on an initial page. | 2949 // Start on an initial page. |
| 2958 GURL url_1(embedded_test_server()->GetURL( | 2950 GURL url_1(embedded_test_server()->GetURL( |
| 2959 "/navigation_controller/simple_page_1.html")); | 2951 "/navigation_controller/simple_page_1.html")); |
| 2960 EXPECT_TRUE(NavigateToURL(shell(), url_1)); | 2952 EXPECT_TRUE(NavigateToURL(shell(), url_1)); |
| 2961 | 2953 |
| 2962 // Name the window. | 2954 // Name the window. |
| 2963 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.name = 'foo';")); | 2955 EXPECT_TRUE(ExecuteScript(shell(), "window.name = 'foo';")); |
| 2964 | 2956 |
| 2965 // Navigate it. | 2957 // Navigate it. |
| 2966 GURL url_2(embedded_test_server()->GetURL( | 2958 GURL url_2(embedded_test_server()->GetURL( |
| 2967 "/navigation_controller/simple_page_2.html")); | 2959 "/navigation_controller/simple_page_2.html")); |
| 2968 EXPECT_TRUE(NavigateToURL(shell(), url_2)); | 2960 EXPECT_TRUE(NavigateToURL(shell(), url_2)); |
| 2969 | 2961 |
| 2970 // Clone the tab and load the page. | 2962 // Clone the tab and load the page. |
| 2971 std::unique_ptr<WebContentsImpl> new_tab( | 2963 std::unique_ptr<WebContentsImpl> new_tab( |
| 2972 static_cast<WebContentsImpl*>(shell()->web_contents()->Clone())); | 2964 static_cast<WebContentsImpl*>(shell()->web_contents()->Clone())); |
| 2973 NavigationController& new_controller = new_tab->GetController(); | 2965 NavigationController& new_controller = new_tab->GetController(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2984 // happened in https://crbug.com/603245 because neither the FrameTreeNode ID nor | 2976 // happened in https://crbug.com/603245 because neither the FrameTreeNode ID nor |
| 2985 // the name of the cloned window matched the root FrameNavigationEntry. | 2977 // the name of the cloned window matched the root FrameNavigationEntry. |
| 2986 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2978 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 2987 CloneAndGoBackWithNamedWindow) { | 2979 CloneAndGoBackWithNamedWindow) { |
| 2988 // Start on an initial page. | 2980 // Start on an initial page. |
| 2989 GURL url_1(embedded_test_server()->GetURL( | 2981 GURL url_1(embedded_test_server()->GetURL( |
| 2990 "/navigation_controller/simple_page_1.html")); | 2982 "/navigation_controller/simple_page_1.html")); |
| 2991 EXPECT_TRUE(NavigateToURL(shell(), url_1)); | 2983 EXPECT_TRUE(NavigateToURL(shell(), url_1)); |
| 2992 | 2984 |
| 2993 // Name the window. | 2985 // Name the window. |
| 2994 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.name = 'foo';")); | 2986 EXPECT_TRUE(ExecuteScript(shell(), "window.name = 'foo';")); |
| 2995 | 2987 |
| 2996 // Navigate it. | 2988 // Navigate it. |
| 2997 GURL url_2(embedded_test_server()->GetURL( | 2989 GURL url_2(embedded_test_server()->GetURL( |
| 2998 "/navigation_controller/simple_page_2.html")); | 2990 "/navigation_controller/simple_page_2.html")); |
| 2999 EXPECT_TRUE(NavigateToURL(shell(), url_2)); | 2991 EXPECT_TRUE(NavigateToURL(shell(), url_2)); |
| 3000 | 2992 |
| 3001 // Clear the name. | 2993 // Clear the name. |
| 3002 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.name = '';")); | 2994 EXPECT_TRUE(ExecuteScript(shell(), "window.name = '';")); |
| 3003 | 2995 |
| 3004 // Navigate it again. | 2996 // Navigate it again. |
| 3005 EXPECT_TRUE(NavigateToURL(shell(), url_1)); | 2997 EXPECT_TRUE(NavigateToURL(shell(), url_1)); |
| 3006 | 2998 |
| 3007 // Clone the tab and load the page. | 2999 // Clone the tab and load the page. |
| 3008 std::unique_ptr<WebContentsImpl> new_tab( | 3000 std::unique_ptr<WebContentsImpl> new_tab( |
| 3009 static_cast<WebContentsImpl*>(shell()->web_contents()->Clone())); | 3001 static_cast<WebContentsImpl*>(shell()->web_contents()->Clone())); |
| 3010 NavigationController& new_controller = new_tab->GetController(); | 3002 NavigationController& new_controller = new_tab->GetController(); |
| 3011 EXPECT_TRUE(new_controller.IsInitialNavigation()); | 3003 EXPECT_TRUE(new_controller.IsInitialNavigation()); |
| 3012 EXPECT_TRUE(new_controller.NeedsReload()); | 3004 EXPECT_TRUE(new_controller.NeedsReload()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3048 root->current_frame_host()->GetSiteInstance(); | 3040 root->current_frame_host()->GetSiteInstance(); |
| 3049 | 3041 |
| 3050 // 2. Add a cross-site subframe. | 3042 // 2. Add a cross-site subframe. |
| 3051 GURL frame_url(embedded_test_server()->GetURL( | 3043 GURL frame_url(embedded_test_server()->GetURL( |
| 3052 "foo.com", "/navigation_controller/simple_page_1.html")); | 3044 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 3053 std::string script = "var iframe = document.createElement('iframe');" | 3045 std::string script = "var iframe = document.createElement('iframe');" |
| 3054 "iframe.src = '" + frame_url.spec() + "';" | 3046 "iframe.src = '" + frame_url.spec() + "';" |
| 3055 "document.body.appendChild(iframe);"; | 3047 "document.body.appendChild(iframe);"; |
| 3056 { | 3048 { |
| 3057 LoadCommittedCapturer capturer(shell()->web_contents()); | 3049 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 3058 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3050 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3059 capturer.Wait(); | 3051 capturer.Wait(); |
| 3060 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 3052 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 3061 } | 3053 } |
| 3062 | 3054 |
| 3063 FrameTreeNode* subframe = root->child_at(0); | 3055 FrameTreeNode* subframe = root->child_at(0); |
| 3064 if (AreAllSitesIsolatedForTesting()) { | 3056 if (AreAllSitesIsolatedForTesting()) { |
| 3065 EXPECT_NE(main_site_instance, | 3057 EXPECT_NE(main_site_instance, |
| 3066 subframe->current_frame_host()->GetSiteInstance()); | 3058 subframe->current_frame_host()->GetSiteInstance()); |
| 3067 } | 3059 } |
| 3068 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3060 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 3069 FrameNavigationEntry* subframe_entry = | 3061 FrameNavigationEntry* subframe_entry = |
| 3070 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 3062 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
| 3071 EXPECT_EQ(frame_url, subframe_entry->url()); | 3063 EXPECT_EQ(frame_url, subframe_entry->url()); |
| 3072 } | 3064 } |
| 3073 | 3065 |
| 3074 // 3. Reload the main frame. | 3066 // 3. Reload the main frame. |
| 3075 { | 3067 { |
| 3076 FrameNavigateParamsCapturer capturer(root); | 3068 FrameNavigateParamsCapturer capturer(root); |
| 3077 controller.Reload(false); | 3069 controller.Reload(false); |
| 3078 capturer.Wait(); | 3070 capturer.Wait(); |
| 3079 EXPECT_EQ(ui::PAGE_TRANSITION_RELOAD, capturer.params().transition); | 3071 EXPECT_EQ(ui::PAGE_TRANSITION_RELOAD, capturer.params().transition); |
| 3080 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 3072 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 3081 EXPECT_FALSE(capturer.details().is_in_page); | 3073 EXPECT_FALSE(capturer.details().is_in_page); |
| 3082 } | 3074 } |
| 3083 | 3075 |
| 3084 // 4. Add the iframe again. | 3076 // 4. Add the iframe again. |
| 3085 { | 3077 { |
| 3086 LoadCommittedCapturer capturer(shell()->web_contents()); | 3078 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 3087 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3079 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3088 capturer.Wait(); | 3080 capturer.Wait(); |
| 3089 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 3081 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 3090 } | 3082 } |
| 3091 if (AreAllSitesIsolatedForTesting()) { | 3083 if (AreAllSitesIsolatedForTesting()) { |
| 3092 EXPECT_NE(main_site_instance, | 3084 EXPECT_NE(main_site_instance, |
| 3093 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 3085 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 3094 } | 3086 } |
| 3095 } | 3087 } |
| 3096 | 3088 |
| 3097 // Verifies that item sequence numbers and document sequence numbers update | 3089 // Verifies that item sequence numbers and document sequence numbers update |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3112 | 3104 |
| 3113 FrameNavigationEntry* frame_entry = | 3105 FrameNavigationEntry* frame_entry = |
| 3114 controller.GetLastCommittedEntry()->GetFrameEntry(root); | 3106 controller.GetLastCommittedEntry()->GetFrameEntry(root); |
| 3115 int64_t isn_1 = frame_entry->item_sequence_number(); | 3107 int64_t isn_1 = frame_entry->item_sequence_number(); |
| 3116 int64_t dsn_1 = frame_entry->document_sequence_number(); | 3108 int64_t dsn_1 = frame_entry->document_sequence_number(); |
| 3117 EXPECT_NE(-1, isn_1); | 3109 EXPECT_NE(-1, isn_1); |
| 3118 EXPECT_NE(-1, dsn_1); | 3110 EXPECT_NE(-1, dsn_1); |
| 3119 | 3111 |
| 3120 // 2. Do an in-page fragment navigation. | 3112 // 2. Do an in-page fragment navigation. |
| 3121 std::string script = "document.getElementById('fraglink').click()"; | 3113 std::string script = "document.getElementById('fraglink').click()"; |
| 3122 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3114 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3123 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3115 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3124 | 3116 |
| 3125 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); | 3117 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); |
| 3126 int64_t isn_2 = frame_entry->item_sequence_number(); | 3118 int64_t isn_2 = frame_entry->item_sequence_number(); |
| 3127 int64_t dsn_2 = frame_entry->document_sequence_number(); | 3119 int64_t dsn_2 = frame_entry->document_sequence_number(); |
| 3128 EXPECT_NE(-1, isn_2); | 3120 EXPECT_NE(-1, isn_2); |
| 3129 EXPECT_NE(isn_1, isn_2); | 3121 EXPECT_NE(isn_1, isn_2); |
| 3130 EXPECT_EQ(dsn_1, dsn_2); | 3122 EXPECT_EQ(dsn_1, dsn_2); |
| 3131 | 3123 |
| 3132 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process. | 3124 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process. |
| 3133 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3125 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 3134 return; | 3126 return; |
| 3135 | 3127 |
| 3136 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. | 3128 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. |
| 3137 { | 3129 { |
| 3138 LoadCommittedCapturer capturer(shell()->web_contents()); | 3130 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 3139 std::string add_script = "var iframe = document.createElement('iframe');" | 3131 std::string add_script = "var iframe = document.createElement('iframe');" |
| 3140 "iframe.src = '" + url.spec() + "';" | 3132 "iframe.src = '" + url.spec() + "';" |
| 3141 "document.body.appendChild(iframe);"; | 3133 "document.body.appendChild(iframe);"; |
| 3142 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), add_script)); | 3134 EXPECT_TRUE(ExecuteScript(root, add_script)); |
| 3143 capturer.Wait(); | 3135 capturer.Wait(); |
| 3144 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 3136 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 3145 } | 3137 } |
| 3146 | 3138 |
| 3147 // The root FrameNavigationEntry hasn't changed. | 3139 // The root FrameNavigationEntry hasn't changed. |
| 3148 EXPECT_EQ(frame_entry, | 3140 EXPECT_EQ(frame_entry, |
| 3149 controller.GetLastCommittedEntry()->GetFrameEntry(root)); | 3141 controller.GetLastCommittedEntry()->GetFrameEntry(root)); |
| 3150 | 3142 |
| 3151 // We should have a unique ISN and DSN for the subframe entry. | 3143 // We should have a unique ISN and DSN for the subframe entry. |
| 3152 FrameTreeNode* subframe = root->child_at(0); | 3144 FrameTreeNode* subframe = root->child_at(0); |
| 3153 FrameNavigationEntry* subframe_entry = | 3145 FrameNavigationEntry* subframe_entry = |
| 3154 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 3146 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
| 3155 int64_t isn_3 = subframe_entry->item_sequence_number(); | 3147 int64_t isn_3 = subframe_entry->item_sequence_number(); |
| 3156 int64_t dsn_3 = subframe_entry->document_sequence_number(); | 3148 int64_t dsn_3 = subframe_entry->document_sequence_number(); |
| 3157 EXPECT_NE(-1, isn_2); | 3149 EXPECT_NE(-1, isn_2); |
| 3158 EXPECT_NE(isn_2, isn_3); | 3150 EXPECT_NE(isn_2, isn_3); |
| 3159 EXPECT_NE(dsn_2, dsn_3); | 3151 EXPECT_NE(dsn_2, dsn_3); |
| 3160 | 3152 |
| 3161 // 4. Do an in-page fragment navigation in the subframe. | 3153 // 4. Do an in-page fragment navigation in the subframe. |
| 3162 EXPECT_TRUE(ExecuteScript(subframe->current_frame_host(), script)); | 3154 EXPECT_TRUE(ExecuteScript(subframe, script)); |
| 3163 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3155 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3164 | 3156 |
| 3165 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 3157 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
| 3166 int64_t isn_4 = subframe_entry->item_sequence_number(); | 3158 int64_t isn_4 = subframe_entry->item_sequence_number(); |
| 3167 int64_t dsn_4 = subframe_entry->document_sequence_number(); | 3159 int64_t dsn_4 = subframe_entry->document_sequence_number(); |
| 3168 EXPECT_NE(-1, isn_4); | 3160 EXPECT_NE(-1, isn_4); |
| 3169 EXPECT_NE(isn_3, isn_4); | 3161 EXPECT_NE(isn_3, isn_4); |
| 3170 EXPECT_EQ(dsn_3, dsn_4); | 3162 EXPECT_EQ(dsn_3, dsn_4); |
| 3171 } | 3163 } |
| 3172 | 3164 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 NavigationEntryImpl* entry = controller.GetPendingEntry(); | 3291 NavigationEntryImpl* entry = controller.GetPendingEntry(); |
| 3300 ASSERT_NE(nullptr, entry); | 3292 ASSERT_NE(nullptr, entry); |
| 3301 EXPECT_EQ(stalled_url, entry->GetURL()); | 3293 EXPECT_EQ(stalled_url, entry->GetURL()); |
| 3302 | 3294 |
| 3303 { | 3295 { |
| 3304 // Now the existing page uses history.replaceState(). | 3296 // Now the existing page uses history.replaceState(). |
| 3305 FrameNavigateParamsCapturer capturer(root); | 3297 FrameNavigateParamsCapturer capturer(root); |
| 3306 capturer.set_wait_for_load(false); | 3298 capturer.set_wait_for_load(false); |
| 3307 std::string script = | 3299 std::string script = |
| 3308 "history.replaceState({}, '', '" + replace_state_filename + "')"; | 3300 "history.replaceState({}, '', '" + replace_state_filename + "')"; |
| 3309 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3301 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3310 capturer.Wait(); | 3302 capturer.Wait(); |
| 3311 | 3303 |
| 3312 // The fact that there was a pending entry shouldn't interfere with the | 3304 // The fact that there was a pending entry shouldn't interfere with the |
| 3313 // classification. | 3305 // classification. |
| 3314 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 3306 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 3315 EXPECT_TRUE(capturer.details().is_in_page); | 3307 EXPECT_TRUE(capturer.details().is_in_page); |
| 3316 } | 3308 } |
| 3317 | 3309 |
| 3318 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 3310 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| 3319 } | 3311 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 ASSERT_NE(nullptr, entry); | 3380 ASSERT_NE(nullptr, entry); |
| 3389 EXPECT_EQ(foo_url, entry->GetURL()); | 3381 EXPECT_EQ(foo_url, entry->GetURL()); |
| 3390 EXPECT_EQ(entry_count, controller.GetEntryCount()); | 3382 EXPECT_EQ(entry_count, controller.GetEntryCount()); |
| 3391 | 3383 |
| 3392 { | 3384 { |
| 3393 // Now the existing page uses history.pushState() while the pending entry | 3385 // Now the existing page uses history.pushState() while the pending entry |
| 3394 // for the other navigation still exists. | 3386 // for the other navigation still exists. |
| 3395 FrameNavigateParamsCapturer capturer(root); | 3387 FrameNavigateParamsCapturer capturer(root); |
| 3396 capturer.set_wait_for_load(false); | 3388 capturer.set_wait_for_load(false); |
| 3397 std::string script = "history.pushState({}, '', 'pushed')"; | 3389 std::string script = "history.pushState({}, '', 'pushed')"; |
| 3398 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3390 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3399 capturer.Wait(); | 3391 capturer.Wait(); |
| 3400 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 3392 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
| 3401 EXPECT_TRUE(capturer.details().is_in_page); | 3393 EXPECT_TRUE(capturer.details().is_in_page); |
| 3402 } | 3394 } |
| 3403 | 3395 |
| 3404 // The in-page navigation should not have replaced the previous entry. | 3396 // The in-page navigation should not have replaced the previous entry. |
| 3405 GURL push_state_url( | 3397 GURL push_state_url( |
| 3406 embedded_test_server()->GetURL("/navigation_controller/pushed")); | 3398 embedded_test_server()->GetURL("/navigation_controller/pushed")); |
| 3407 EXPECT_EQ(entry_count + 1, controller.GetEntryCount()); | 3399 EXPECT_EQ(entry_count + 1, controller.GetEntryCount()); |
| 3408 EXPECT_EQ(push_state_url, controller.GetLastCommittedEntry()->GetURL()); | 3400 EXPECT_EQ(push_state_url, controller.GetLastCommittedEntry()->GetURL()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3425 | 3417 |
| 3426 // Load an initial page. | 3418 // Load an initial page. |
| 3427 GURL start_url(embedded_test_server()->GetURL( | 3419 GURL start_url(embedded_test_server()->GetURL( |
| 3428 "/navigation_controller/beforeunload_replacestate_1.html")); | 3420 "/navigation_controller/beforeunload_replacestate_1.html")); |
| 3429 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | 3421 EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
| 3430 EXPECT_EQ(1, controller.GetEntryCount()); | 3422 EXPECT_EQ(1, controller.GetEntryCount()); |
| 3431 EXPECT_EQ(start_url, controller.GetLastCommittedEntry()->GetURL()); | 3423 EXPECT_EQ(start_url, controller.GetLastCommittedEntry()->GetURL()); |
| 3432 | 3424 |
| 3433 // Go to the second page. | 3425 // Go to the second page. |
| 3434 std::string script = "document.getElementById('thelink').click()"; | 3426 std::string script = "document.getElementById('thelink').click()"; |
| 3435 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3427 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3436 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3428 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3437 EXPECT_EQ(2, controller.GetEntryCount()); | 3429 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3438 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3430 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3439 | 3431 |
| 3440 // Go back to the first page, which never completes. The attempt to unload the | 3432 // Go back to the first page, which never completes. The attempt to unload the |
| 3441 // second page, though, causes it to do a replaceState(). | 3433 // second page, though, causes it to do a replaceState(). |
| 3442 TestNavigationManager manager(shell()->web_contents(), start_url); | 3434 TestNavigationManager manager(shell()->web_contents(), start_url); |
| 3443 controller.GoBack(); | 3435 controller.GoBack(); |
| 3444 manager.WaitForWillStartRequest(); | 3436 manager.WaitForWillStartRequest(); |
| 3445 | 3437 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3494 shell()->web_contents()->GetController().GoForward(); | 3486 shell()->web_contents()->GetController().GoForward(); |
| 3495 forward_load_observer.Wait(); | 3487 forward_load_observer.Wait(); |
| 3496 } | 3488 } |
| 3497 | 3489 |
| 3498 GURL url3(embedded_test_server()->GetURL( | 3490 GURL url3(embedded_test_server()->GetURL( |
| 3499 "/navigation_controller/page_with_iframe.html")); | 3491 "/navigation_controller/page_with_iframe.html")); |
| 3500 { | 3492 { |
| 3501 // location.replace() to cause an inert commit. | 3493 // location.replace() to cause an inert commit. |
| 3502 TestNavigationObserver replace_load_observer(shell()->web_contents()); | 3494 TestNavigationObserver replace_load_observer(shell()->web_contents()); |
| 3503 std::string script = "location.replace('" + url3.spec() + "')"; | 3495 std::string script = "location.replace('" + url3.spec() + "')"; |
| 3504 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3496 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3505 replace_load_observer.Wait(); | 3497 replace_load_observer.Wait(); |
| 3506 } | 3498 } |
| 3507 | 3499 |
| 3508 { | 3500 { |
| 3509 // Go back to url2. | 3501 // Go back to url2. |
| 3510 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3502 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 3511 shell()->web_contents()->GetController().GoBack(); | 3503 shell()->web_contents()->GetController().GoBack(); |
| 3512 back_load_observer.Wait(); | 3504 back_load_observer.Wait(); |
| 3513 | 3505 |
| 3514 // Make sure the URL is correct for both the entry and the main frame, and | 3506 // Make sure the URL is correct for both the entry and the main frame, and |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3576 NavigateFrameToURL(root->child_at(0), frame_url); | 3568 NavigateFrameToURL(root->child_at(0), frame_url); |
| 3577 capturer.Wait(); | 3569 capturer.Wait(); |
| 3578 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 3570 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 3579 } | 3571 } |
| 3580 | 3572 |
| 3581 { | 3573 { |
| 3582 // history.replaceState(). | 3574 // history.replaceState(). |
| 3583 FrameNavigateParamsCapturer capturer(root); | 3575 FrameNavigateParamsCapturer capturer(root); |
| 3584 std::string script = | 3576 std::string script = |
| 3585 "history.replaceState({}, 'replaced', 'replaced')"; | 3577 "history.replaceState({}, 'replaced', 'replaced')"; |
| 3586 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3578 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3587 capturer.Wait(); | 3579 capturer.Wait(); |
| 3588 } | 3580 } |
| 3589 | 3581 |
| 3590 { | 3582 { |
| 3591 // Go back in the iframe. | 3583 // Go back in the iframe. |
| 3592 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3584 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 3593 shell()->web_contents()->GetController().GoBack(); | 3585 shell()->web_contents()->GetController().GoBack(); |
| 3594 back_load_observer.Wait(); | 3586 back_load_observer.Wait(); |
| 3595 } | 3587 } |
| 3596 | 3588 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 ->GetFrameTree() | 3725 ->GetFrameTree() |
| 3734 ->root(); | 3726 ->root(); |
| 3735 RenderProcessKilledObserver kill_observer(shell()->web_contents()); | 3727 RenderProcessKilledObserver kill_observer(shell()->web_contents()); |
| 3736 | 3728 |
| 3737 // Redirect so that we can use ReloadOriginalRequest. | 3729 // Redirect so that we can use ReloadOriginalRequest. |
| 3738 GURL redirect_url(embedded_test_server()->GetURL( | 3730 GURL redirect_url(embedded_test_server()->GetURL( |
| 3739 "foo.com", "/navigation_controller/simple_page_1.html")); | 3731 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 3740 { | 3732 { |
| 3741 std::string script = "location.replace('" + redirect_url.spec() + "');"; | 3733 std::string script = "location.replace('" + redirect_url.spec() + "');"; |
| 3742 FrameNavigateParamsCapturer capturer(root); | 3734 FrameNavigateParamsCapturer capturer(root); |
| 3743 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 3735 EXPECT_TRUE(ExecuteScript(shell(), script)); |
| 3744 capturer.Wait(); | 3736 capturer.Wait(); |
| 3745 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 3737 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 3746 capturer.params().transition); | 3738 capturer.params().transition); |
| 3747 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 3739 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| 3748 } | 3740 } |
| 3749 | 3741 |
| 3750 // Modify an entry in the session history and reload the original request. | 3742 // Modify an entry in the session history and reload the original request. |
| 3751 { | 3743 { |
| 3752 // We first send a replaceState() to the renderer, which will cause the | 3744 // We first send a replaceState() to the renderer, which will cause the |
| 3753 // renderer to send back a DidCommitProvisionalLoad. Immediately after, | 3745 // renderer to send back a DidCommitProvisionalLoad. Immediately after, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3771 capturer.set_wait_for_load(false); | 3763 capturer.set_wait_for_load(false); |
| 3772 capturer.set_navigations_remaining(2); | 3764 capturer.set_navigations_remaining(2); |
| 3773 capturer.Wait(); | 3765 capturer.Wait(); |
| 3774 EXPECT_EQ(2U, capturer.all_details().size()); | 3766 EXPECT_EQ(2U, capturer.all_details().size()); |
| 3775 EXPECT_EQ(modified_url, capturer.all_params()[0].url); | 3767 EXPECT_EQ(modified_url, capturer.all_params()[0].url); |
| 3776 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 3768 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
| 3777 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 3769 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
| 3778 } | 3770 } |
| 3779 | 3771 |
| 3780 // Make sure the renderer is still alive. | 3772 // Make sure the renderer is still alive. |
| 3781 EXPECT_TRUE( | 3773 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');")); |
| 3782 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | |
| 3783 } | 3774 } |
| 3784 | 3775 |
| 3785 // This test shows that the initial "about:blank" URL is elided from the | 3776 // This test shows that the initial "about:blank" URL is elided from the |
| 3786 // navigation history of a subframe when it is loaded. | 3777 // navigation history of a subframe when it is loaded. |
| 3787 // | 3778 // |
| 3788 // It also prevents regression for an in-page navigation renderer kill when | 3779 // It also prevents regression for an in-page navigation renderer kill when |
| 3789 // going back after an in-page navigation in the main frame is followed by an | 3780 // going back after an in-page navigation in the main frame is followed by an |
| 3790 // auto subframe navigation, due to a bug in HistoryEntry::CloneAndReplace. | 3781 // auto subframe navigation, due to a bug in HistoryEntry::CloneAndReplace. |
| 3791 // See https://crbug.com/612713. | 3782 // See https://crbug.com/612713. |
| 3792 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3783 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3803 | 3794 |
| 3804 EXPECT_EQ(1, controller.GetEntryCount()); | 3795 EXPECT_EQ(1, controller.GetEntryCount()); |
| 3805 EXPECT_EQ(1, RendererHistoryLength(shell())); | 3796 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 3806 | 3797 |
| 3807 // Add an iframe with no 'src'. | 3798 // Add an iframe with no 'src'. |
| 3808 | 3799 |
| 3809 std::string script = | 3800 std::string script = |
| 3810 "var iframe = document.createElement('iframe');" | 3801 "var iframe = document.createElement('iframe');" |
| 3811 "iframe.id = 'frame';" | 3802 "iframe.id = 'frame';" |
| 3812 "document.body.appendChild(iframe);"; | 3803 "document.body.appendChild(iframe);"; |
| 3813 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3804 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3814 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3805 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3815 | 3806 |
| 3816 EXPECT_EQ(1, controller.GetEntryCount()); | 3807 EXPECT_EQ(1, controller.GetEntryCount()); |
| 3817 EXPECT_EQ(1, RendererHistoryLength(shell())); | 3808 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 3818 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3809 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3819 | 3810 |
| 3820 ASSERT_EQ(1U, root->child_count()); | 3811 ASSERT_EQ(1U, root->child_count()); |
| 3821 FrameTreeNode* frame = root->child_at(0); | 3812 FrameTreeNode* frame = root->child_at(0); |
| 3822 ASSERT_NE(nullptr, frame); | 3813 ASSERT_NE(nullptr, frame); |
| 3823 | 3814 |
| 3824 GURL blank_url(url::kAboutBlankURL); | 3815 GURL blank_url(url::kAboutBlankURL); |
| 3825 EXPECT_EQ(blank_url, frame->current_url()); | 3816 EXPECT_EQ(blank_url, frame->current_url()); |
| 3826 | 3817 |
| 3827 // Now create a new navigation entry. Note that the old navigation entry has | 3818 // Now create a new navigation entry. Note that the old navigation entry has |
| 3828 // "about:blank" as the URL in the iframe. | 3819 // "about:blank" as the URL in the iframe. |
| 3829 | 3820 |
| 3830 script = "history.pushState({}, '', 'notarealurl.html')"; | 3821 script = "history.pushState({}, '', 'notarealurl.html')"; |
| 3831 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3822 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3832 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3823 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3833 | 3824 |
| 3834 EXPECT_EQ(2, controller.GetEntryCount()); | 3825 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3835 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3826 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3836 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3827 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3837 | 3828 |
| 3838 // Load the iframe; the initial "about:blank" URL should be elided and thus we | 3829 // Load the iframe; the initial "about:blank" URL should be elided and thus we |
| 3839 // shouldn't get a new navigation entry. | 3830 // shouldn't get a new navigation entry. |
| 3840 | 3831 |
| 3841 GURL frame_url = embedded_test_server()->GetURL( | 3832 GURL frame_url = embedded_test_server()->GetURL( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3933 | 3924 |
| 3934 // Add an iframe with a 'src'. | 3925 // Add an iframe with a 'src'. |
| 3935 | 3926 |
| 3936 GURL frame_url_1 = embedded_test_server()->GetURL( | 3927 GURL frame_url_1 = embedded_test_server()->GetURL( |
| 3937 "/navigation_controller/simple_page_1.html"); | 3928 "/navigation_controller/simple_page_1.html"); |
| 3938 std::string script = | 3929 std::string script = |
| 3939 "var iframe = document.createElement('iframe');" | 3930 "var iframe = document.createElement('iframe');" |
| 3940 "iframe.src = '" + frame_url_1.spec() + "';" | 3931 "iframe.src = '" + frame_url_1.spec() + "';" |
| 3941 "iframe.id = 'frame';" | 3932 "iframe.id = 'frame';" |
| 3942 "document.body.appendChild(iframe);"; | 3933 "document.body.appendChild(iframe);"; |
| 3943 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3934 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3944 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3935 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3945 | 3936 |
| 3946 EXPECT_EQ(1, controller.GetEntryCount()); | 3937 EXPECT_EQ(1, controller.GetEntryCount()); |
| 3947 EXPECT_EQ(1, RendererHistoryLength(shell())); | 3938 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 3948 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3939 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3949 | 3940 |
| 3950 ASSERT_EQ(1U, root->child_count()); | 3941 ASSERT_EQ(1U, root->child_count()); |
| 3951 FrameTreeNode* frame = root->child_at(0); | 3942 FrameTreeNode* frame = root->child_at(0); |
| 3952 ASSERT_NE(nullptr, frame); | 3943 ASSERT_NE(nullptr, frame); |
| 3953 | 3944 |
| 3954 EXPECT_EQ(frame_url_1, frame->current_url()); | 3945 EXPECT_EQ(frame_url_1, frame->current_url()); |
| 3955 | 3946 |
| 3956 // Do a fragment navigation, creating a new navigation entry. Note that the | 3947 // Do a fragment navigation, creating a new navigation entry. Note that the |
| 3957 // old navigation entry has frame_url_1 as the URL in the iframe. | 3948 // old navigation entry has frame_url_1 as the URL in the iframe. |
| 3958 | 3949 |
| 3959 script = "document.getElementById('fraglink').click()"; | 3950 script = "document.getElementById('fraglink').click()"; |
| 3960 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3951 EXPECT_TRUE(ExecuteScript(root, script)); |
| 3961 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3952 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3962 | 3953 |
| 3963 EXPECT_EQ(2, controller.GetEntryCount()); | 3954 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3964 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3955 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3965 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3956 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3966 | 3957 |
| 3967 EXPECT_EQ(frame_url_1, frame->current_url()); | 3958 EXPECT_EQ(frame_url_1, frame->current_url()); |
| 3968 | 3959 |
| 3969 // Navigate the iframe; unlike the test "BackToAboutBlankIframe" above, this | 3960 // Navigate the iframe; unlike the test "BackToAboutBlankIframe" above, this |
| 3970 // _will_ create a new navigation entry. | 3961 // _will_ create a new navigation entry. |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4413 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4404 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4414 | 4405 |
| 4415 // Do a replaceState to a URL that will redirect when we come back to it via | 4406 // Do a replaceState to a URL that will redirect when we come back to it via |
| 4416 // session history. | 4407 // session history. |
| 4417 GURL url_3(embedded_test_server()->GetURL( | 4408 GURL url_3(embedded_test_server()->GetURL( |
| 4418 "foo.com", "/navigation_controller/page_with_links.html")); | 4409 "foo.com", "/navigation_controller/page_with_links.html")); |
| 4419 { | 4410 { |
| 4420 TestNavigationObserver observer(shell()->web_contents()); | 4411 TestNavigationObserver observer(shell()->web_contents()); |
| 4421 std::string script = | 4412 std::string script = |
| 4422 "history.replaceState({}, '', '/server-redirect?" + url_3.spec() + "')"; | 4413 "history.replaceState({}, '', '/server-redirect?" + url_3.spec() + "')"; |
| 4423 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 4414 EXPECT_TRUE(ExecuteScript(root, script)); |
| 4424 observer.Wait(); | 4415 observer.Wait(); |
| 4425 } | 4416 } |
| 4426 | 4417 |
| 4427 // Go back. | 4418 // Go back. |
| 4428 controller.GoBack(); | 4419 controller.GoBack(); |
| 4429 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4420 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4430 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4421 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 4431 EXPECT_EQ(url_1, root->current_url()); | 4422 EXPECT_EQ(url_1, root->current_url()); |
| 4432 | 4423 |
| 4433 // Clone the tab without navigating it. | 4424 // Clone the tab without navigating it. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4477 EXPECT_EQ(-1, root_entry->post_id()); | 4468 EXPECT_EQ(-1, root_entry->post_id()); |
| 4478 EXPECT_EQ("GET", frame_entry->method()); | 4469 EXPECT_EQ("GET", frame_entry->method()); |
| 4479 EXPECT_EQ(-1, frame_entry->post_id()); | 4470 EXPECT_EQ(-1, frame_entry->post_id()); |
| 4480 EXPECT_FALSE(entry->GetHasPostData()); | 4471 EXPECT_FALSE(entry->GetHasPostData()); |
| 4481 EXPECT_EQ(-1, entry->GetPostID()); | 4472 EXPECT_EQ(-1, entry->GetPostID()); |
| 4482 } | 4473 } |
| 4483 | 4474 |
| 4484 // Submit the form. | 4475 // Submit the form. |
| 4485 TestNavigationObserver observer(shell()->web_contents(), 1); | 4476 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 4486 EXPECT_TRUE(ExecuteScript( | 4477 EXPECT_TRUE(ExecuteScript( |
| 4487 shell()->web_contents(), | 4478 shell(), "window.domAutomationController.send(submitForm('isubmit'))")); |
| 4488 "window.domAutomationController.send(submitForm('isubmit'))")); | |
| 4489 observer.Wait(); | 4479 observer.Wait(); |
| 4490 | 4480 |
| 4491 EXPECT_EQ(2, controller.GetEntryCount()); | 4481 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4492 { | 4482 { |
| 4493 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 4483 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 4494 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); | 4484 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); |
| 4495 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame); | 4485 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame); |
| 4496 EXPECT_NE(nullptr, root_entry); | 4486 EXPECT_NE(nullptr, root_entry); |
| 4497 EXPECT_NE(nullptr, frame_entry); | 4487 EXPECT_NE(nullptr, frame_entry); |
| 4498 EXPECT_EQ("GET", root_entry->method()); | 4488 EXPECT_EQ("GET", root_entry->method()); |
| 4499 EXPECT_EQ(-1, root_entry->post_id()); | 4489 EXPECT_EQ(-1, root_entry->post_id()); |
| 4500 EXPECT_EQ("POST", frame_entry->method()); | 4490 EXPECT_EQ("POST", frame_entry->method()); |
| 4501 // TODO(clamy): Check the post id as well when PlzNavigate handles it | 4491 // TODO(clamy): Check the post id as well when PlzNavigate handles it |
| 4502 // properly. | 4492 // properly. |
| 4503 if (!IsBrowserSideNavigationEnabled()) | 4493 if (!IsBrowserSideNavigationEnabled()) |
| 4504 EXPECT_NE(-1, frame_entry->post_id()); | 4494 EXPECT_NE(-1, frame_entry->post_id()); |
| 4505 EXPECT_FALSE(entry->GetHasPostData()); | 4495 EXPECT_FALSE(entry->GetHasPostData()); |
| 4506 EXPECT_EQ(-1, entry->GetPostID()); | 4496 EXPECT_EQ(-1, entry->GetPostID()); |
| 4507 } | 4497 } |
| 4508 } | 4498 } |
| 4509 | 4499 |
| 4510 } // namespace content | 4500 } // namespace content |
| OLD | NEW |