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

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

Issue 1542743002: [RDHI] Refactored blocked_loaders_map_ to key by render frame route id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nasko nit Created 4 years, 10 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 (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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 request.headers = base::StringPrintf("Origin: %s\r\n", origin); 132 request.headers = base::StringPrintf("Origin: %s\r\n", origin);
133 return request; 133 return request;
134 } 134 }
135 135
136 void TryCreateDuplicateRequestIds(Shell* shell, bool block_loaders) { 136 void TryCreateDuplicateRequestIds(Shell* shell, bool block_loaders) {
137 NavigateToURL(shell, GURL("http://foo.com/simple_page.html")); 137 NavigateToURL(shell, GURL("http://foo.com/simple_page.html"));
138 RenderFrameHost* rfh = shell->web_contents()->GetMainFrame(); 138 RenderFrameHost* rfh = shell->web_contents()->GetMainFrame();
139 139
140 if (block_loaders) { 140 if (block_loaders) {
141 // Test the case where loaders are placed into blocked_loaders_map_. 141 // Test the case where loaders are placed into blocked_loaders_map_.
142 int child_id = rfh->GetProcess()->GetID(); 142 ResourceDispatcherHost::BlockRequestsForFrameFromUI(rfh);
143 BrowserThread::PostTask(
144 BrowserThread::IO, FROM_HERE,
145 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute,
146 base::Unretained(ResourceDispatcherHost::Get()), child_id,
147 rfh->GetRoutingID()));
148 } 143 }
149 144
150 // URLRequestSlowDownloadJob waits for another request to kFinishDownloadUrl 145 // URLRequestSlowDownloadJob waits for another request to kFinishDownloadUrl
151 // to finish all pending requests. It is never sent, so the following URL 146 // to finish all pending requests. It is never sent, so the following URL
152 // blocks indefinitely, which is good because the request stays alive and the 147 // blocks indefinitely, which is good because the request stays alive and the
153 // test can try to reuse the request id without a race. 148 // test can try to reuse the request id without a race.
154 const char* blocking_url = net::URLRequestSlowDownloadJob::kUnknownSizeUrl; 149 const char* blocking_url = net::URLRequestSlowDownloadJob::kUnknownSizeUrl;
155 ResourceHostMsg_Request request(CreateXHRRequest(blocking_url)); 150 ResourceHostMsg_Request request(CreateXHRRequest(blocking_url));
156 151
157 // Use the same request id twice. 152 // Use the same request id twice.
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Renderer process should not be able to create multiple requests with the same 493 // Renderer process should not be able to create multiple requests with the same
499 // id. 494 // id.
500 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, InvalidRequestId) { 495 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, InvalidRequestId) {
501 // Existing loader in pending_loaders_. 496 // Existing loader in pending_loaders_.
502 TryCreateDuplicateRequestIds(shell(), false); 497 TryCreateDuplicateRequestIds(shell(), false);
503 // Existing loader in blocked_loaders_map_. 498 // Existing loader in blocked_loaders_map_.
504 TryCreateDuplicateRequestIds(shell(), true); 499 TryCreateDuplicateRequestIds(shell(), true);
505 } 500 }
506 501
507 } // namespace content 502 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698