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

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

Issue 2550113002: Send a subtree of same-process PageStates for back/forward child frames.
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3459 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 3459 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3460 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 3460 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
3461 3461
3462 // The entry should have a FrameNavigationEntry for the blank subframe. 3462 // The entry should have a FrameNavigationEntry for the blank subframe.
3463 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 3463 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3464 ASSERT_EQ(1U, entry->root_node()->children.size()); 3464 ASSERT_EQ(1U, entry->root_node()->children.size());
3465 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); 3465 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
3466 } 3466 }
3467 } 3467 }
3468 3468
3469 // Verify that we don't clobber any content injected into the initial blank page
3470 // if we go back to an about:blank/#foo subframe. See https://crbug.com/NNNNNN.
3471 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3472 FrameNavigationEntry_RecreatedBlankFragmentSubframe) {
3473 // 1. Start on a page that injects content into an about:blank/#foo iframe.
3474 GURL main_url(embedded_test_server()->GetURL(
3475 "/navigation_controller/inject_into_blank_iframe_with_fragment.html"));
3476 // TODO(creis): Don't rewrite about:blank/#foo to about:blank.
3477 GURL blank_url(url::kAboutBlankURL);
3478 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3479 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
3480 shell()->web_contents()->GetController());
3481 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3482 ->GetFrameTree()
3483 ->root();
3484 ASSERT_EQ(1U, root->child_count());
3485 ASSERT_EQ(0U, root->child_at(0)->child_count());
3486 EXPECT_EQ(main_url, root->current_url());
3487 EXPECT_EQ(blank_url, root->child_at(0)->current_url());
3488
3489 // Verify that the parent was able to script the iframe.
3490 std::string expected_text("Injected text");
3491 {
3492 std::string value;
3493 EXPECT_TRUE(ExecuteScriptAndExtractString(
3494 root->child_at(0),
3495 "domAutomationController.send(document.body.innerHTML)", &value));
3496 EXPECT_EQ(expected_text, value);
3497 }
3498
3499 EXPECT_EQ(1, controller.GetEntryCount());
3500 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3501 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
3502
3503 // The entry should have a FrameNavigationEntry for the blank subframe.
3504 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3505 ASSERT_EQ(1U, entry->root_node()->children.size());
3506 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
3507 }
3508
3509 // 2. Navigate the main frame, destroying the frames.
3510 GURL main_url_2(embedded_test_server()->GetURL(
3511 "/navigation_controller/simple_page_1.html"));
3512 EXPECT_TRUE(NavigateToURL(shell(), main_url_2));
3513 ASSERT_EQ(0U, root->child_count());
3514 EXPECT_EQ(main_url_2, root->current_url());
3515
3516 EXPECT_EQ(2, controller.GetEntryCount());
3517 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3518
3519 // 3. Go back, recreating the iframe.
3520 {
3521 TestNavigationObserver back_load_observer(shell()->web_contents());
3522 controller.GoBack();
3523 back_load_observer.Wait();
3524 }
3525 ASSERT_EQ(1U, root->child_count());
3526 EXPECT_EQ(main_url, root->current_url());
3527 EXPECT_EQ(blank_url, root->child_at(0)->current_url());
3528
3529 // Verify that the parent was able to script the iframe.
3530 {
3531 std::string value;
3532 EXPECT_TRUE(ExecuteScriptAndExtractString(
3533 root->child_at(0),
3534 "domAutomationController.send(document.body.innerHTML)", &value));
3535 EXPECT_EQ(expected_text, value);
3536 }
3537
3538 EXPECT_EQ(2, controller.GetEntryCount());
3539 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3540 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
3541
3542 // The entry should have a FrameNavigationEntry for the blank subframe.
3543 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3544 ASSERT_EQ(1U, entry->root_node()->children.size());
3545 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
3546 }
3547 }
3548
3469 // Ensure we don't crash if an onload handler removes an about:blank frame after 3549 // Ensure we don't crash if an onload handler removes an about:blank frame after
3470 // recreating it on a back/forward. See https://crbug.com/638166. 3550 // recreating it on a back/forward. See https://crbug.com/638166.
3471 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3551 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3472 FrameNavigationEntry_RemoveRecreatedBlankSubframe) { 3552 FrameNavigationEntry_RemoveRecreatedBlankSubframe) {
3473 // 1. Start on a page that removes its about:blank iframe during onload. 3553 // 1. Start on a page that removes its about:blank iframe during onload.
3474 GURL main_url(embedded_test_server()->GetURL( 3554 GURL main_url(embedded_test_server()->GetURL(
3475 "/navigation_controller/remove_blank_iframe_on_load.html")); 3555 "/navigation_controller/remove_blank_iframe_on_load.html"));
3476 GURL blank_url(url::kAboutBlankURL); 3556 GURL blank_url(url::kAboutBlankURL);
3477 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3557 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3478 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( 3558 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
(...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after
7030 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), 7110 NavigationHandleCommitObserver handle_observer(shell()->web_contents(),
7031 kFragmentURL); 7111 kFragmentURL);
7032 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); 7112 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL));
7033 7113
7034 EXPECT_TRUE(handle_observer.has_committed()); 7114 EXPECT_TRUE(handle_observer.has_committed());
7035 EXPECT_TRUE(handle_observer.was_same_page()); 7115 EXPECT_TRUE(handle_observer.was_same_page());
7036 EXPECT_FALSE(handle_observer.was_renderer_initiated()); 7116 EXPECT_FALSE(handle_observer.was_renderer_initiated());
7037 } 7117 }
7038 7118
7039 } // namespace content 7119 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698