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

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

Issue 2523583003: Fix some flaky tests. (Closed)
Patch Set: 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
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 8339 matching lines...) Expand 10 before | Expand all | Expand 10 after
8350 EXPECT_EQ(1, child_count); 8350 EXPECT_EQ(1, child_count);
8351 8351
8352 // Add an unload handler to B's subframe. 8352 // Add an unload handler to B's subframe.
8353 EXPECT_TRUE( 8353 EXPECT_TRUE(
8354 ExecuteScript(root->child_at(0)->child_at(0)->current_frame_host(), 8354 ExecuteScript(root->child_at(0)->child_at(0)->current_frame_host(),
8355 "window.onunload=function(e){\n" 8355 "window.onunload=function(e){\n"
8356 " window.location = '#navigate';\n" 8356 " window.location = '#navigate';\n"
8357 "};\n")); 8357 "};\n"));
8358 8358
8359 // Navigate B's subframe to a cross-site C. 8359 // Navigate B's subframe to a cross-site C.
8360 RenderFrameDeletedObserver deleted_observer(
8361 root->child_at(0)->child_at(0)->current_frame_host());
nasko 2016/11/23 17:48:29 I agree that moving this code makes sense. However
Alexander Semashko 2016/11/23 18:38:08 c.com is loaded in the third-level frame, because
nasko 2016/11/24 00:00:43 Ah, yes!
8360 std::string script = 8362 std::string script =
8361 std::string("window.document.getElementById('child-0').src = \"") + 8363 std::string("window.document.getElementById('child-0').src = \"") +
8362 embedded_test_server() 8364 embedded_test_server()
8363 ->GetURL("c.com", "/cross_site_iframe_factory.html") 8365 ->GetURL("c.com", "/cross_site_iframe_factory.html")
8364 .spec() + 8366 .spec() +
8365 "\""; 8367 "\"";
8366 EXPECT_TRUE( 8368 EXPECT_TRUE(
8367 ExecuteScript(root->child_at(0)->current_frame_host(), script.c_str())); 8369 ExecuteScript(root->child_at(0)->current_frame_host(), script.c_str()));
8368 8370
8369 // Wait until B's subframe RenderFrameHost is destroyed. 8371 // Wait until B's subframe RenderFrameHost is destroyed.
8370 RenderFrameDeletedObserver deleted_observer(
8371 root->child_at(0)->child_at(0)->current_frame_host());
8372 deleted_observer.WaitUntilDeleted(); 8372 deleted_observer.WaitUntilDeleted();
8373 8373
8374 // Check that C's subframe is alive and the navigation in the unload handler 8374 // Check that C's subframe is alive and the navigation in the unload handler
8375 // was ignored. 8375 // was ignored.
8376 EXPECT_TRUE(ExecuteScriptAndExtractInt( 8376 EXPECT_TRUE(ExecuteScriptAndExtractInt(
8377 root->child_at(0)->child_at(0)->current_frame_host(), 8377 root->child_at(0)->child_at(0)->current_frame_host(),
8378 "window.domAutomationController.send(frames.length);", &child_count)); 8378 "window.domAutomationController.send(frames.length);", &child_count));
8379 EXPECT_EQ(0, child_count); 8379 EXPECT_EQ(0, child_count);
8380 8380
8381 EXPECT_EQ( 8381 EXPECT_EQ(
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
8652 // hit the 20 seconds delay before https://crbug.com/657195 was fixed. 8652 // hit the 20 seconds delay before https://crbug.com/657195 was fixed.
8653 EXPECT_TRUE(NavigateToURL(shell(), page_url)); 8653 EXPECT_TRUE(NavigateToURL(shell(), page_url));
8654 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL()); 8654 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL());
8655 8655
8656 // Note: even if the test fails and for some reason, the test has not timed 8656 // Note: even if the test fails and for some reason, the test has not timed
8657 // out by this point, the test teardown code will still hit a DCHECK when it 8657 // out by this point, the test teardown code will still hit a DCHECK when it
8658 // calls AssertNoURLRequests() in the shell's URLRequestContext destructor. 8658 // calls AssertNoURLRequests() in the shell's URLRequestContext destructor.
8659 } 8659 }
8660 8660
8661 } // namespace content 8661 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/test/browser_test_utils.cc » ('j') | content/public/test/test_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698