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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1816733002: Change TestFrameNavigationObserver to wait for load stop instead of commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add capability to wait for commit and fix RenderViewHostPendingDeletionIsNotReused Created 4 years, 9 months 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/test/test_frame_navigation_observer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 // Check that the current sandbox flags are updated but the effective 2838 // Check that the current sandbox flags are updated but the effective
2839 // sandbox flags are not. 2839 // sandbox flags are not.
2840 blink::WebSandboxFlags expected_flags = 2840 blink::WebSandboxFlags expected_flags =
2841 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts & 2841 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts &
2842 ~blink::WebSandboxFlags::AutomaticFeatures; 2842 ~blink::WebSandboxFlags::AutomaticFeatures;
2843 EXPECT_EQ(expected_flags, root->child_at(1)->pending_sandbox_flags()); 2843 EXPECT_EQ(expected_flags, root->child_at(1)->pending_sandbox_flags());
2844 EXPECT_EQ(blink::WebSandboxFlags::None, 2844 EXPECT_EQ(blink::WebSandboxFlags::None,
2845 root->child_at(1)->effective_sandbox_flags()); 2845 root->child_at(1)->effective_sandbox_flags());
2846 2846
2847 // Navigate the second subframe to a page on bar.com. This will trigger a 2847 // Navigate the second subframe to a page on bar.com. This will trigger a
2848 // remote-to-local frame swap in bar.com's process. The target page has 2848 // remote-to-local frame swap in bar.com's process.
2849 // another frame, so use TestFrameNavigationObserver to wait for all frames
2850 // to be loaded.
2851 TestFrameNavigationObserver frame_observer(root->child_at(1), 2);
2852 GURL bar_url(embedded_test_server()->GetURL( 2849 GURL bar_url(embedded_test_server()->GetURL(
2853 "bar.com", "/frame_tree/page_with_one_frame.html")); 2850 "bar.com", "/frame_tree/page_with_one_frame.html"));
2854 NavigateFrameToURL(root->child_at(1), bar_url); 2851 NavigateFrameToURL(root->child_at(1), bar_url);
2855 frame_observer.Wait();
2856 EXPECT_EQ(bar_url, root->child_at(1)->current_url()); 2852 EXPECT_EQ(bar_url, root->child_at(1)->current_url());
2857 ASSERT_EQ(1U, root->child_at(1)->child_count()); 2853 ASSERT_EQ(1U, root->child_at(1)->child_count());
2858 2854
2859 // Confirm that the browser process has updated the current sandbox flags. 2855 // Confirm that the browser process has updated the current sandbox flags.
2860 EXPECT_EQ(expected_flags, root->child_at(1)->pending_sandbox_flags()); 2856 EXPECT_EQ(expected_flags, root->child_at(1)->pending_sandbox_flags());
2861 EXPECT_EQ(expected_flags, root->child_at(1)->effective_sandbox_flags()); 2857 EXPECT_EQ(expected_flags, root->child_at(1)->effective_sandbox_flags());
2862 2858
2863 // Opening a popup in the sandboxed second frame should fail. 2859 // Opening a popup in the sandboxed second frame should fail.
2864 bool success = false; 2860 bool success = false;
2865 EXPECT_TRUE( 2861 EXPECT_TRUE(
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4146 // process. 4142 // process.
4147 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); 4143 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter();
4148 rfh->GetProcess()->AddFilter(filter.get()); 4144 rfh->GetProcess()->AddFilter(filter.get());
4149 4145
4150 // Navigate to B. This must wait for DidCommitProvisionalLoad, as opposed to 4146 // Navigate to B. This must wait for DidCommitProvisionalLoad, as opposed to
4151 // DidStopLoading, since otherwise the SwapOut timer might call OnSwappedOut 4147 // DidStopLoading, since otherwise the SwapOut timer might call OnSwappedOut
4152 // and destroy |rvh| before its pending deletion status is checked. 4148 // and destroy |rvh| before its pending deletion status is checked.
4153 GURL b_url(embedded_test_server()->GetURL("b.com", "/title2.html")); 4149 GURL b_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
4154 TestFrameNavigationObserver commit_observer(root); 4150 TestFrameNavigationObserver commit_observer(root);
4155 shell()->LoadURL(b_url); 4151 shell()->LoadURL(b_url);
4156 commit_observer.Wait(); 4152 commit_observer.WaitForCommit();
4157 4153
4158 // Since the SwapOut ACK for A->B is dropped, the first page's 4154 // Since the SwapOut ACK for A->B is dropped, the first page's
4159 // RenderFrameHost and RenderViewHost should be pending deletion after the 4155 // RenderFrameHost and RenderViewHost should be pending deletion after the
4160 // last navigation. 4156 // last navigation.
4161 EXPECT_TRUE(root->render_manager()->IsPendingDeletion(rfh)); 4157 EXPECT_TRUE(root->render_manager()->IsPendingDeletion(rfh));
4162 EXPECT_TRUE(rvh->is_pending_deletion()); 4158 EXPECT_TRUE(rvh->is_pending_deletion());
4163 4159
4164 // Wait for process A to exit so we can reinitialize it cleanly for the next 4160 // Wait for process A to exit so we can reinitialize it cleanly for the next
4165 // navigation. This can be removed once https://crbug.com/535246 is fixed. 4161 // navigation. This can be removed once https://crbug.com/535246 is fixed.
4166 RenderProcessHostWatcher process_exit_observer( 4162 RenderProcessHostWatcher process_exit_observer(
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
5499 EXPECT_EQ(blink::WebSandboxFlags::None, 5495 EXPECT_EQ(blink::WebSandboxFlags::None,
5500 root->child_at(0)->effective_sandbox_flags()); 5496 root->child_at(0)->effective_sandbox_flags());
5501 5497
5502 // Navigate child frame so that the sandbox flags take effect. Use a page 5498 // Navigate child frame so that the sandbox flags take effect. Use a page
5503 // with three levels of frames and make sure all frames properly inherit 5499 // with three levels of frames and make sure all frames properly inherit
5504 // sandbox flags. 5500 // sandbox flags.
5505 GURL frame_url(embedded_test_server()->GetURL( 5501 GURL frame_url(embedded_test_server()->GetURL(
5506 "b.com", "/cross_site_iframe_factory.html?b(c(d))")); 5502 "b.com", "/cross_site_iframe_factory.html?b(c(d))"));
5507 TestFrameNavigationObserver frame_observer(root->child_at(0)); 5503 TestFrameNavigationObserver frame_observer(root->child_at(0));
5508 NavigateFrameToURL(root->child_at(0), frame_url); 5504 NavigateFrameToURL(root->child_at(0), frame_url);
5509 frame_observer.Wait(); 5505 frame_observer.Wait();
alexmos 2016/03/21 23:00:24 nit: This doesn't look like it's needed anymore (o
nasko 2016/03/21 23:42:54 Done.
5510 // Wait for subframes to load as well. 5506 // Wait for subframes to load as well.
5511 ASSERT_TRUE(WaitForLoadStop(shell()->web_contents())); 5507 ASSERT_TRUE(WaitForLoadStop(shell()->web_contents()));
5512 5508
5513 // Check each new frame's sandbox flags on the browser process side. 5509 // Check each new frame's sandbox flags on the browser process side.
5514 FrameTreeNode* b_child = root->child_at(0); 5510 FrameTreeNode* b_child = root->child_at(0);
5515 FrameTreeNode* c_child = b_child->child_at(0); 5511 FrameTreeNode* c_child = b_child->child_at(0);
5516 FrameTreeNode* d_child = c_child->child_at(0); 5512 FrameTreeNode* d_child = c_child->child_at(0);
5517 EXPECT_EQ(expected_flags, b_child->effective_sandbox_flags()); 5513 EXPECT_EQ(expected_flags, b_child->effective_sandbox_flags());
5518 EXPECT_EQ(expected_flags, c_child->effective_sandbox_flags()); 5514 EXPECT_EQ(expected_flags, c_child->effective_sandbox_flags());
5519 EXPECT_EQ(expected_flags, d_child->effective_sandbox_flags()); 5515 EXPECT_EQ(expected_flags, d_child->effective_sandbox_flags());
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
6029 EXPECT_EQ(b_url, root->current_url()); 6025 EXPECT_EQ(b_url, root->current_url());
6030 6026
6031 // Verify that the same RenderViewHost is preserved and that it is no longer 6027 // Verify that the same RenderViewHost is preserved and that it is no longer
6032 // in swapped out state. 6028 // in swapped out state.
6033 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( 6029 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost(
6034 root->current_frame_host()->GetSiteInstance())); 6030 root->current_frame_host()->GetSiteInstance()));
6035 EXPECT_FALSE(rvh->is_swapped_out_); 6031 EXPECT_FALSE(rvh->is_swapped_out_);
6036 } 6032 }
6037 6033
6038 } // namespace content 6034 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/test_frame_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698