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

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

Issue 2630843002: Fix race in SecurityExploitBrowserTest and SiteIsolationStatsGathererBrowserTest (Closed)
Patch Set: fix tests -- can't overidde BrowserTestBase::SetUp() as it runs the test itself Created 3 years, 11 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/child/site_isolation_stats_gatherer_browsertest.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // The goal of these tests will be to "simulate" exploited renderer processes, 174 // The goal of these tests will be to "simulate" exploited renderer processes,
175 // which can send arbitrary IPC messages and confuse browser process internal 175 // which can send arbitrary IPC messages and confuse browser process internal
176 // state, leading to security bugs. We are trying to verify that the browser 176 // state, leading to security bugs. We are trying to verify that the browser
177 // doesn't perform any dangerous operations in such cases. 177 // doesn't perform any dangerous operations in such cases.
178 class SecurityExploitBrowserTest : public ContentBrowserTest { 178 class SecurityExploitBrowserTest : public ContentBrowserTest {
179 public: 179 public:
180 SecurityExploitBrowserTest() {} 180 SecurityExploitBrowserTest() {}
181 181
182 void SetUpCommandLine(base::CommandLine* command_line) override { 182 void SetUpCommandLine(base::CommandLine* command_line) override {
183 ASSERT_TRUE(embedded_test_server()->Start()); 183 // EmbeddedTestServer::InitializeAndListen() initializes its |base_url_|
184 // which is required below. This cannot invoke Start() however as that kicks
185 // off the "EmbeddedTestServer IO Thread" which then races with
186 // initialization in ContentBrowserTest::SetUp(), http://crbug.com/674545.
187 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
184 188
185 // Add a host resolver rule to map all outgoing requests to the test server. 189 // Add a host resolver rule to map all outgoing requests to the test server.
186 // This allows us to use "real" hostnames in URLs, which we can use to 190 // This allows us to use "real" hostnames in URLs, which we can use to
187 // create arbitrary SiteInstances. 191 // create arbitrary SiteInstances.
188 command_line->AppendSwitchASCII( 192 command_line->AppendSwitchASCII(
189 switches::kHostResolverRules, 193 switches::kHostResolverRules,
190 "MAP * " + 194 "MAP * " +
191 net::HostPortPair::FromURL(embedded_test_server()->base_url()) 195 net::HostPortPair::FromURL(embedded_test_server()->base_url())
192 .ToString() + 196 .ToString() +
193 ",EXCLUDE localhost"); 197 ",EXCLUDE localhost");
194 } 198 }
195 199
196 void SetUpOnMainThread() override { 200 void SetUpOnMainThread() override {
201 // Complete the manual Start() after ContentBrowserTest's own
202 // initialization, ref. comment on InitializeAndListen() above.
203 embedded_test_server()->StartAcceptingConnections();
204
197 BrowserThread::PostTask( 205 BrowserThread::PostTask(
198 BrowserThread::IO, FROM_HERE, 206 BrowserThread::IO, FROM_HERE,
199 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler)); 207 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler));
200 } 208 }
201 209
202 protected: 210 protected:
203 // Tests that a given file path sent in a FrameHostMsg_RunFileChooser will 211 // Tests that a given file path sent in a FrameHostMsg_RunFileChooser will
204 // cause renderer to be killed. 212 // cause renderer to be killed.
205 void TestFileChooserWithPath(const base::FilePath& path); 213 void TestFileChooserWithPath(const base::FilePath& path);
206 }; 214 };
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // separate task of the message loop, so ensure that the process is still 561 // separate task of the message loop, so ensure that the process is still
554 // considered alive. 562 // considered alive.
555 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection()); 563 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection());
556 564
557 exit_observer.Wait(); 565 exit_observer.Wait();
558 EXPECT_FALSE(exit_observer.did_exit_normally()); 566 EXPECT_FALSE(exit_observer.did_exit_normally());
559 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 567 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
560 } 568 }
561 569
562 } // namespace content 570 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/site_isolation_stats_gatherer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698