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