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

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

Issue 1874923002: Fix flakiness when disabling swap out timer in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 2353
2354 // Navigate the main tab to the site of the popup. This will cause the 2354 // Navigate the main tab to the site of the popup. This will cause the
2355 // RenderView for b.com in the main tab to be recreated. If the issue 2355 // RenderView for b.com in the main tab to be recreated. If the issue
2356 // is not fixed, this will result in process crash and failing test. 2356 // is not fixed, this will result in process crash and failing test.
2357 EXPECT_TRUE(NavigateToURL( 2357 EXPECT_TRUE(NavigateToURL(
2358 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); 2358 shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
2359 } 2359 }
2360 2360
2361 // Ensure that we don't crash the renderer in CreateRenderView if a proxy goes 2361 // Ensure that we don't crash the renderer in CreateRenderView if a proxy goes
2362 // away between swapout and the next navigation. See https://crbug.com/581912. 2362 // away between swapout and the next navigation. See https://crbug.com/581912.
2363 // Dr.Memory reports a use-after-free in this test, thus it may be flaky on
2364 // Windows. See https://crbug.com/600957.
2365 #if defined(OS_WIN)
2366 #define MAYBE_CreateRenderViewAfterProcessKillAndClosedProxy \
2367 DISABLED_CreateRenderViewAfterProcessKillAndClosedProxy
2368 #else
2369 #define MAYBE_CreateRenderViewAfterProcessKillAndClosedProxy \
2370 CreateRenderViewAfterProcessKillAndClosedProxy
2371 #endif
2372 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 2363 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
2373 MAYBE_CreateRenderViewAfterProcessKillAndClosedProxy) { 2364 CreateRenderViewAfterProcessKillAndClosedProxy) {
2374 StartEmbeddedServer(); 2365 StartEmbeddedServer();
2375 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2366 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
2376 ->GetFrameTree() 2367 ->GetFrameTree()
2377 ->root(); 2368 ->root();
2378 2369
2379 // Give an initial page an unload handler that never completes. 2370 // Give an initial page an unload handler that never completes.
2380 EXPECT_TRUE(NavigateToURL( 2371 EXPECT_TRUE(NavigateToURL(
2381 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); 2372 shell(), embedded_test_server()->GetURL("a.com", "/title1.html")));
2382 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), 2373 EXPECT_TRUE(ExecuteScript(root->current_frame_host(),
2383 "window.onunload=function(e){ while(1); };\n")); 2374 "window.onunload=function(e){ while(1); };\n"));
2384 2375
2385 // Open a popup in the same process. 2376 // Open a popup in the same process.
2386 Shell* new_shell = 2377 Shell* new_shell =
2387 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "foo"); 2378 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "foo");
2388 FrameTreeNode* popup_root = 2379 FrameTreeNode* popup_root =
2389 static_cast<WebContentsImpl*>(new_shell->web_contents()) 2380 static_cast<WebContentsImpl*>(new_shell->web_contents())
2390 ->GetFrameTree() 2381 ->GetFrameTree()
2391 ->root(); 2382 ->root();
2392 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), 2383 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
2393 new_shell->web_contents()->GetSiteInstance()); 2384 new_shell->web_contents()->GetSiteInstance());
2394 2385
2395 // Navigate the first tab to a different site, and only wait for commit, not 2386 // Navigate the first tab to a different site, and only wait for commit, not
2396 // load stop. 2387 // load stop.
2397 RenderFrameHostImpl* rfh_a = root->current_frame_host(); 2388 RenderFrameHostImpl* rfh_a = root->current_frame_host();
2389 rfh_a->DisableSwapOutTimerForTesting();
2398 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); 2390 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance();
2399 TestFrameNavigationObserver commit_observer(root); 2391 TestFrameNavigationObserver commit_observer(root);
2400 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); 2392 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html"));
2401 commit_observer.WaitForCommit(); 2393 commit_observer.WaitForCommit();
2402 rfh_a->ResetSwapOutTimerForTesting();
2403 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 2394 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
2404 new_shell->web_contents()->GetSiteInstance()); 2395 new_shell->web_contents()->GetSiteInstance());
2405 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); 2396 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a));
2406 2397
2407 // The previous RFH should still be pending deletion, as we wait for either 2398 // The previous RFH should still be pending deletion, as we wait for either
2408 // the SwapOut ACK or a timeout. 2399 // the SwapOut ACK or a timeout.
2409 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); 2400 ASSERT_TRUE(rfh_a->IsRenderFrameLive());
2410 ASSERT_FALSE(rfh_a->is_active()); 2401 ASSERT_FALSE(rfh_a->is_active());
2411 2402
2412 // The corresponding RVH should not be pending deletion due to the proxy. 2403 // The corresponding RVH should not be pending deletion due to the proxy.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 2439
2449 // Give an initial page an unload handler that never completes. 2440 // Give an initial page an unload handler that never completes.
2450 EXPECT_TRUE(NavigateToURL( 2441 EXPECT_TRUE(NavigateToURL(
2451 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); 2442 shell(), embedded_test_server()->GetURL("a.com", "/title1.html")));
2452 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), 2443 EXPECT_TRUE(ExecuteScript(root->current_frame_host(),
2453 "window.onunload=function(e){ while(1); };\n")); 2444 "window.onunload=function(e){ while(1); };\n"));
2454 2445
2455 // Navigate the tab to a different site, and only wait for commit, not load 2446 // Navigate the tab to a different site, and only wait for commit, not load
2456 // stop. 2447 // stop.
2457 RenderFrameHostImpl* rfh_a = root->current_frame_host(); 2448 RenderFrameHostImpl* rfh_a = root->current_frame_host();
2449 rfh_a->DisableSwapOutTimerForTesting();
2458 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); 2450 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance();
2459 TestFrameNavigationObserver commit_observer(root); 2451 TestFrameNavigationObserver commit_observer(root);
2460 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); 2452 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html"));
2461 commit_observer.WaitForCommit(); 2453 commit_observer.WaitForCommit();
2462 rfh_a->ResetSwapOutTimerForTesting();
2463 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance()); 2454 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance());
2464 2455
2465 // The previous RFH and RVH should still be pending deletion, as we wait for 2456 // The previous RFH and RVH should still be pending deletion, as we wait for
2466 // either the SwapOut ACK or a timeout. 2457 // either the SwapOut ACK or a timeout.
2467 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); 2458 ASSERT_TRUE(rfh_a->IsRenderFrameLive());
2468 ASSERT_FALSE(rfh_a->is_active()); 2459 ASSERT_FALSE(rfh_a->is_active());
2469 EXPECT_TRUE(root->render_manager()->IsViewPendingDeletion( 2460 EXPECT_TRUE(root->render_manager()->IsViewPendingDeletion(
2470 rfh_a->render_view_host())); 2461 rfh_a->render_view_host()));
2471 2462
2472 // Open a popup in the new B process. 2463 // Open a popup in the new B process.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 web_contents->GetRenderManagerForTesting()->speculative_frame_host()); 2544 web_contents->GetRenderManagerForTesting()->speculative_frame_host());
2554 } else { 2545 } else {
2555 EXPECT_FALSE( 2546 EXPECT_FALSE(
2556 web_contents->GetRenderManagerForTesting()->pending_frame_host()); 2547 web_contents->GetRenderManagerForTesting()->pending_frame_host());
2557 } 2548 }
2558 2549
2559 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 2550 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
2560 } 2551 }
2561 2552
2562 } // namespace content 2553 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698