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

Side by Side Diff: content/child/site_isolation_stats_gatherer_browsertest.cc

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/pattern.h" 7 #include "base/strings/pattern.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 "valid.xml", 143 "valid.xml",
144 "xml.txt", 144 "xml.txt",
145 }; 145 };
146 146
147 for (const char* resource : blocked_resources) { 147 for (const char* resource : blocked_resources) {
148 SCOPED_TRACE(base::StringPrintf("... while testing page: %s", resource)); 148 SCOPED_TRACE(base::StringPrintf("... while testing page: %s", resource));
149 base::HistogramTester histograms; 149 base::HistogramTester histograms;
150 150
151 bool was_blocked; 151 bool was_blocked;
152 ASSERT_TRUE(ExecuteScriptAndExtractBool( 152 ASSERT_TRUE(ExecuteScriptAndExtractBool(
153 shell()->web_contents(), 153 shell(), base::StringPrintf("sendRequest(\"%s\");", resource),
154 base::StringPrintf("sendRequest(\"%s\");", resource), &was_blocked)); 154 &was_blocked));
155 ASSERT_FALSE(was_blocked); 155 ASSERT_FALSE(was_blocked);
156 156
157 InspectHistograms(histograms, true, resource); 157 InspectHistograms(histograms, true, resource);
158 } 158 }
159 159
160 // These files should be allowed for XHR under the document blocking policy. 160 // These files should be allowed for XHR under the document blocking policy.
161 const char* allowed_resources[] = {"js.html", 161 const char* allowed_resources[] = {"js.html",
162 "comment_js.html", 162 "comment_js.html",
163 "js.xml", 163 "js.xml",
164 "js.json", 164 "js.json",
165 "js.txt", 165 "js.txt",
166 "img.html", 166 "img.html",
167 "img.xml", 167 "img.xml",
168 "img.json", 168 "img.json",
169 "img.txt", 169 "img.txt",
170 "comment_js.html"}; 170 "comment_js.html"};
171 for (const char* resource : allowed_resources) { 171 for (const char* resource : allowed_resources) {
172 SCOPED_TRACE(base::StringPrintf("... while testing page: %s", resource)); 172 SCOPED_TRACE(base::StringPrintf("... while testing page: %s", resource));
173 base::HistogramTester histograms; 173 base::HistogramTester histograms;
174 174
175 bool was_blocked; 175 bool was_blocked;
176 ASSERT_TRUE(ExecuteScriptAndExtractBool( 176 ASSERT_TRUE(ExecuteScriptAndExtractBool(
177 shell()->web_contents(), 177 shell(), base::StringPrintf("sendRequest(\"%s\");", resource),
178 base::StringPrintf("sendRequest(\"%s\");", resource), &was_blocked)); 178 &was_blocked));
179 ASSERT_FALSE(was_blocked); 179 ASSERT_FALSE(was_blocked);
180 180
181 InspectHistograms(histograms, false, resource); 181 InspectHistograms(histograms, false, resource);
182 } 182 }
183 } 183 }
184 184
185 IN_PROC_BROWSER_TEST_F(SiteIsolationStatsGathererBrowserTest, 185 IN_PROC_BROWSER_TEST_F(SiteIsolationStatsGathererBrowserTest,
186 CrossSiteDocumentBlockingForDifferentTargets) { 186 CrossSiteDocumentBlockingForDifferentTargets) {
187 // This webpage loads a cross-site HTML page in different targets such as 187 // This webpage loads a cross-site HTML page in different targets such as
188 // <img>,<link>,<embed>, etc. Since the requested document is blocked, and one 188 // <img>,<link>,<embed>, etc. Since the requested document is blocked, and one
189 // character string (' ') is returned instead, this tests that the renderer 189 // character string (' ') is returned instead, this tests that the renderer
190 // does not crash even when it receives a response body which is " ", whose 190 // does not crash even when it receives a response body which is " ", whose
191 // length is different from what's described in "content-length" for such 191 // length is different from what's described in "content-length" for such
192 // different targets. 192 // different targets.
193 193
194 // TODO(nick): Split up these cases, and add positive assertions here about 194 // TODO(nick): Split up these cases, and add positive assertions here about
195 // what actually happens in these various resource-block cases. 195 // what actually happens in these various resource-block cases.
196 GURL foo("http://foo.com/cross_site_document_request_target.html"); 196 GURL foo("http://foo.com/cross_site_document_request_target.html");
197 NavigateToURL(shell(), foo); 197 NavigateToURL(shell(), foo);
198 } 198 }
199 199
200 } // namespace content 200 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698