OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3294 // FrameNavigationEntry_RecreatedInjectedBlankSubframe). | 3294 // FrameNavigationEntry_RecreatedInjectedBlankSubframe). |
3295 // | 3295 // |
3296 // This test worked before and after the fix for https://crbug.com/657896, but | 3296 // This test worked before and after the fix for https://crbug.com/657896, but |
3297 // it failed with a preliminary version of the fix. | 3297 // it failed with a preliminary version of the fix. |
3298 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3298 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3299 FrameNavigationEntry_RecreatedInjectedSrcdocSubframe) { | 3299 FrameNavigationEntry_RecreatedInjectedSrcdocSubframe) { |
3300 // 1. Start on a page that injects a nested iframe srcdoc which contains a | 3300 // 1. Start on a page that injects a nested iframe srcdoc which contains a |
3301 // nested iframe. | 3301 // nested iframe. |
3302 GURL main_url(embedded_test_server()->GetURL( | 3302 GURL main_url(embedded_test_server()->GetURL( |
3303 "/navigation_controller/inject_iframe_srcdoc_with_nested_frame.html")); | 3303 "/navigation_controller/inject_iframe_srcdoc_with_nested_frame.html")); |
3304 GURL blank_url(url::kAboutBlankURL); | 3304 GURL srcdoc_url(content::kAboutSrcDocURL); |
3305 GURL inner_url( | 3305 GURL inner_url( |
3306 embedded_test_server()->GetURL("/navigation_controller/form.html")); | 3306 embedded_test_server()->GetURL("/navigation_controller/form.html")); |
3307 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3307 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3308 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | 3308 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
3309 shell()->web_contents()->GetController()); | 3309 shell()->web_contents()->GetController()); |
3310 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3310 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3311 ->GetFrameTree() | 3311 ->GetFrameTree() |
3312 ->root(); | 3312 ->root(); |
3313 | 3313 |
3314 // Verify that the inner iframe was able to load. | 3314 // Verify that the inner iframe was able to load. |
3315 ASSERT_EQ(1U, root->child_count()); | 3315 ASSERT_EQ(1U, root->child_count()); |
3316 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 3316 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
3317 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); | 3317 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); |
3318 EXPECT_EQ(main_url, root->current_url()); | 3318 EXPECT_EQ(main_url, root->current_url()); |
3319 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3319 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); |
3320 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3320 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3321 | 3321 |
3322 EXPECT_EQ(1, controller.GetEntryCount()); | 3322 EXPECT_EQ(1, controller.GetEntryCount()); |
3323 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3323 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3324 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 3324 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3325 | 3325 |
3326 // The entry should have FrameNavigationEntries for the subframes. | 3326 // The entry should have FrameNavigationEntries for the subframes. |
3327 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3327 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
3328 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3328 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3329 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | 3329 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); |
3330 EXPECT_EQ(inner_url, | 3330 EXPECT_EQ(inner_url, |
3331 entry->root_node()->children[0]->children[0]->frame_entry->url()); | 3331 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3332 } | 3332 } |
3333 | 3333 |
3334 // Set a value in the form which will be stored in the PageState. | 3334 // Set a value in the form which will be stored in the PageState. |
3335 EXPECT_TRUE( | 3335 EXPECT_TRUE( |
3336 ExecuteScript(root->child_at(0)->child_at(0), | 3336 ExecuteScript(root->child_at(0)->child_at(0), |
3337 "document.getElementById('itext').value = 'modified';")); | 3337 "document.getElementById('itext').value = 'modified';")); |
3338 | 3338 |
3339 // 2. Navigate the main frame same-site, destroying the subframes. | 3339 // 2. Navigate the main frame same-site, destroying the subframes. |
3340 GURL main_url_2(embedded_test_server()->GetURL( | 3340 GURL main_url_2(embedded_test_server()->GetURL( |
3341 "/navigation_controller/simple_page_1.html")); | 3341 "/navigation_controller/simple_page_1.html")); |
3342 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 3342 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
3343 ASSERT_EQ(0U, root->child_count()); | 3343 ASSERT_EQ(0U, root->child_count()); |
3344 EXPECT_EQ(main_url_2, root->current_url()); | 3344 EXPECT_EQ(main_url_2, root->current_url()); |
3345 | 3345 |
3346 EXPECT_EQ(2, controller.GetEntryCount()); | 3346 EXPECT_EQ(2, controller.GetEntryCount()); |
3347 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3347 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3348 | 3348 |
3349 // 3. Go back, recreating the subframes. | 3349 // 3. Go back, recreating the subframes. |
3350 { | 3350 { |
3351 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3351 TestNavigationObserver back_load_observer(shell()->web_contents()); |
3352 controller.GoBack(); | 3352 controller.GoBack(); |
3353 back_load_observer.Wait(); | 3353 back_load_observer.Wait(); |
3354 } | 3354 } |
3355 ASSERT_EQ(1U, root->child_count()); | 3355 ASSERT_EQ(1U, root->child_count()); |
3356 // TODO(creis): This line is unexpectedly failing in PlzNavigate, so the test | |
3357 // is disabled there for now. | |
3358 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 3356 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
3359 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); | 3357 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); |
3360 EXPECT_EQ(main_url, root->current_url()); | 3358 EXPECT_EQ(main_url, root->current_url()); |
3361 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3359 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); |
3362 | 3360 |
3363 // Verify that the inner iframe went to the correct URL. | 3361 // Verify that the inner iframe went to the correct URL. |
3364 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3362 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3365 | 3363 |
3366 EXPECT_EQ(2, controller.GetEntryCount()); | 3364 EXPECT_EQ(2, controller.GetEntryCount()); |
3367 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3365 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3368 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3366 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3369 | 3367 |
3370 // The entry should have FrameNavigationEntries for the subframes. | 3368 // The entry should have FrameNavigationEntries for the subframes. |
3371 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3369 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
3372 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3370 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3373 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | 3371 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); |
3374 EXPECT_EQ(inner_url, | 3372 EXPECT_EQ(inner_url, |
3375 entry->root_node()->children[0]->children[0]->frame_entry->url()); | 3373 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3376 } | 3374 } |
3377 | 3375 |
3378 // With injected iframe srcdoc pages, we do restore form values from | 3376 // With injected iframe srcdoc pages, we do restore form values from |
3379 // PageState. | 3377 // PageState. |
3380 std::string form_value; | 3378 std::string form_value; |
3381 EXPECT_TRUE( | 3379 EXPECT_TRUE( |
3382 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), | 3380 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), |
3383 "window.domAutomationController.send(" | 3381 "window.domAutomationController.send(" |
(...skipping 3645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7029 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), | 7027 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
7030 kFragmentURL); | 7028 kFragmentURL); |
7031 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 7029 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
7032 | 7030 |
7033 EXPECT_TRUE(handle_observer.has_committed()); | 7031 EXPECT_TRUE(handle_observer.has_committed()); |
7034 EXPECT_TRUE(handle_observer.was_same_page()); | 7032 EXPECT_TRUE(handle_observer.was_same_page()); |
7035 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 7033 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
7036 } | 7034 } |
7037 | 7035 |
7038 } // namespace content | 7036 } // namespace content |
OLD | NEW |