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

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

Issue 1506093002: Don't create unexpected OOPIFs in --isolate-extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nasko's suggestions Created 5 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/render_frame_host_manager.cc » ('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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/frame_host/frame_navigation_entry.h" 8 #include "content/browser/frame_host/frame_navigation_entry.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 2673 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
2674 2674
2675 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); 2675 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe);
2676 int64 isn_4 = subframe_entry->item_sequence_number(); 2676 int64 isn_4 = subframe_entry->item_sequence_number();
2677 int64 dsn_4 = subframe_entry->document_sequence_number(); 2677 int64 dsn_4 = subframe_entry->document_sequence_number();
2678 EXPECT_NE(-1, isn_4); 2678 EXPECT_NE(-1, isn_4);
2679 EXPECT_NE(isn_3, isn_4); 2679 EXPECT_NE(isn_3, isn_4);
2680 EXPECT_EQ(dsn_3, dsn_4); 2680 EXPECT_EQ(dsn_3, dsn_4);
2681 } 2681 }
2682 2682
2683 // Support a set of tests that isolate only a subset of sites with
2684 // out-of-process iframes (OOPIFs).
2685 class NavigationControllerOopifBrowserTest
2686 : public NavigationControllerBrowserTest {
2687 public:
2688 NavigationControllerOopifBrowserTest() {}
2689
2690 void SetUpCommandLine(base::CommandLine* command_line) override {
2691 // TODO(creis): Turn on OOPIF framework without isolating all sites.
2692 }
2693
2694 private:
2695 DISALLOW_COPY_AND_ASSIGN(NavigationControllerOopifBrowserTest);
2696 };
2697
2698 // Verify that restoring a NavigationEntry with cross-site subframes does not
2699 // create out-of-process iframes unless the current SiteIsolationPolicy says to.
2700 IN_PROC_BROWSER_TEST_F(NavigationControllerOopifBrowserTest,
2701 RestoreWithoutExtraOopifs) {
2702 // 1. Start on a page with a data URL iframe.
2703 GURL main_url_a(embedded_test_server()->GetURL(
2704 "a.com", "/navigation_controller/page_with_data_iframe.html"));
2705 GURL data_url("data:text/html,Subframe");
2706 EXPECT_TRUE(NavigateToURL(shell(), main_url_a));
2707 const NavigationControllerImpl& controller =
2708 static_cast<const NavigationControllerImpl&>(
2709 shell()->web_contents()->GetController());
2710 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
2711 ->GetFrameTree()
2712 ->root();
2713 EXPECT_EQ(main_url_a, root->current_url());
2714 EXPECT_EQ(data_url, root->child_at(0)->current_url());
2715
2716 // 2. Navigate the iframe cross-site.
2717 GURL frame_url_b(embedded_test_server()->GetURL(
2718 "b.com", "/navigation_controller/simple_page_1.html"));
2719 {
2720 TestNavigationObserver capturer(shell()->web_contents());
nasko 2015/12/08 19:08:42 nit: It is no longer a capturer, but an observer.
Charlie Reis 2015/12/08 19:30:51 Done.
2721 NavigateFrameToURL(root->child_at(0), frame_url_b);
2722 capturer.Wait();
2723 }
2724 EXPECT_EQ(main_url_a, root->current_url());
2725 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url());
2726
2727 EXPECT_EQ(2, controller.GetEntryCount());
2728 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
2729 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
2730
2731 // 3. Create a NavigationEntry with the same PageState as |entry2|.
2732 scoped_ptr<NavigationEntryImpl> restored_entry =
2733 NavigationEntryImpl::FromNavigationEntry(
2734 NavigationControllerImpl::CreateNavigationEntry(
2735 main_url_a, Referrer(), ui::PAGE_TRANSITION_RELOAD, false,
2736 std::string(), controller.GetBrowserContext()));
2737 restored_entry->SetPageID(0);
2738 EXPECT_EQ(0U, restored_entry->root_node()->children.size());
2739 restored_entry->SetPageState(entry2->GetPageState());
2740
2741 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
2742 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
2743 // The entry should have no SiteInstance in the FrameNavigationEntry for the
2744 // b.com subframe.
2745 EXPECT_FALSE(
2746 restored_entry->root_node()->children[0]->frame_entry->site_instance());
2747 } else {
2748 // There are no subframe FrameNavigationEntries by default.
2749 EXPECT_EQ(0U, restored_entry->root_node()->children.size());
2750 }
2751
2752 // 4. Restore the new entry in a new tab and verify the correct URLs load.
2753 std::vector<scoped_ptr<NavigationEntry>> entries;
2754 entries.push_back(restored_entry.Pass());
2755 Shell* new_shell = Shell::CreateNewWindow(
2756 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size());
2757 FrameTreeNode* new_root =
2758 static_cast<WebContentsImpl*>(new_shell->web_contents())
2759 ->GetFrameTree()
2760 ->root();
2761 NavigationControllerImpl& new_controller =
2762 static_cast<NavigationControllerImpl&>(
2763 new_shell->web_contents()->GetController());
2764 new_controller.Restore(
2765 entries.size() - 1,
2766 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries);
2767 ASSERT_EQ(0u, entries.size());
2768 {
2769 TestNavigationObserver restore_observer(new_shell->web_contents());
2770 new_controller.LoadIfNecessary();
2771 restore_observer.Wait();
2772 }
2773 ASSERT_EQ(1U, new_root->child_count());
2774 EXPECT_EQ(main_url_a, new_root->current_url());
2775 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url());
2776
2777 // The subframe should only be in a different SiteInstance if OOPIFs are
2778 // required for all sites.
2779 if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) {
2780 EXPECT_NE(new_root->current_frame_host()->GetSiteInstance(),
2781 new_root->child_at(0)->current_frame_host()->GetSiteInstance());
2782 } else {
2783 EXPECT_EQ(new_root->current_frame_host()->GetSiteInstance(),
2784 new_root->child_at(0)->current_frame_host()->GetSiteInstance());
2785 }
2786 }
2787
2683 namespace { 2788 namespace {
2684 2789
2685 // Loads |start_url|, then loads |stalled_url| which stalls. While the page is 2790 // Loads |start_url|, then loads |stalled_url| which stalls. While the page is
2686 // stalled, an in-page navigation happens. Make sure that all the navigations 2791 // stalled, an in-page navigation happens. Make sure that all the navigations
2687 // are properly classified. 2792 // are properly classified.
2688 void DoReplaceStateWhilePending(Shell* shell, 2793 void DoReplaceStateWhilePending(Shell* shell,
2689 const GURL& start_url, 2794 const GURL& start_url,
2690 const GURL& stalled_url, 2795 const GURL& stalled_url,
2691 const std::string& replace_state_filename) { 2796 const std::string& replace_state_filename) {
2692 NavigationControllerImpl& controller = 2797 NavigationControllerImpl& controller =
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 EXPECT_EQ(original_url, capturer.all_params()[1].url); 3186 EXPECT_EQ(original_url, capturer.all_params()[1].url);
3082 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); 3187 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL());
3083 } 3188 }
3084 3189
3085 // Make sure the renderer is still alive. 3190 // Make sure the renderer is still alive.
3086 EXPECT_TRUE( 3191 EXPECT_TRUE(
3087 ExecuteScript(shell()->web_contents(), "console.log('Success');")); 3192 ExecuteScript(shell()->web_contents(), "console.log('Success');"));
3088 } 3193 }
3089 3194
3090 } // namespace content 3195 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698