OLD | NEW |
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 // Note that although this is not a "browser" test, it runs as part of | 5 // Note that although this is not a "browser" test, it runs as part of |
6 // browser_tests. This is because WebKit does not work properly if it is | 6 // browser_tests. This is because WebKit does not work properly if it is |
7 // shutdown and re-initialized. Since browser_tests runs each test in a | 7 // shutdown and re-initialized. Since browser_tests runs each test in a |
8 // new process, this avoids the problem. | 8 // new process, this avoids the problem. |
9 | 9 |
10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" | 10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Don't want to try to create a GPU process. | 77 // Don't want to try to create a GPU process. |
78 command_line->AppendSwitch(switches::kDisableGpu); | 78 command_line->AppendSwitch(switches::kDisableGpu); |
79 #endif | 79 #endif |
80 } | 80 } |
81 | 81 |
82 void SetUpOnMainThread() override { | 82 void SetUpOnMainThread() override { |
83 render_view_routing_id_ = | 83 render_view_routing_id_ = |
84 GetWebContents()->GetRenderViewHost()->GetRoutingID(); | 84 GetWebContents()->GetRenderViewHost()->GetRoutingID(); |
85 extractor_.reset(new PhishingDOMFeatureExtractor(&clock_)); | 85 extractor_.reset(new PhishingDOMFeatureExtractor(&clock_)); |
86 | 86 |
87 ASSERT_TRUE(StartTestServer()); | 87 embedded_test_server()->RegisterRequestHandler( |
| 88 base::Bind(&PhishingDOMFeatureExtractorTest::HandleRequest, |
| 89 base::Unretained(this))); |
| 90 ASSERT_TRUE(embedded_test_server()->Start()); |
88 host_resolver()->AddRule("*", "127.0.0.1"); | 91 host_resolver()->AddRule("*", "127.0.0.1"); |
89 } | 92 } |
90 | 93 |
91 // Runs the DOMFeatureExtractor on the RenderView, waiting for the | 94 // Runs the DOMFeatureExtractor on the RenderView, waiting for the |
92 // completion callback. Returns the success boolean from the callback. | 95 // completion callback. Returns the success boolean from the callback. |
93 bool ExtractFeatures(FeatureMap* features) { | 96 bool ExtractFeatures(FeatureMap* features) { |
94 success_ = false; | 97 success_ = false; |
95 PostTaskToInProcessRendererAndWait( | 98 PostTaskToInProcessRendererAndWait( |
96 base::Bind(&PhishingDOMFeatureExtractorTest::ExtractFeaturesInternal, | 99 base::Bind(&PhishingDOMFeatureExtractorTest::ExtractFeaturesInternal, |
97 base::Unretained(this), | 100 base::Unretained(this), |
(...skipping 27 matching lines...) Expand all Loading... |
125 | 128 |
126 // Does the actual work of removing the iframe "frame1" from the document. | 129 // Does the actual work of removing the iframe "frame1" from the document. |
127 void RemoveIframe() { | 130 void RemoveIframe() { |
128 blink::WebFrame* main_frame = GetWebFrame(); | 131 blink::WebFrame* main_frame = GetWebFrame(); |
129 ASSERT_TRUE(main_frame); | 132 ASSERT_TRUE(main_frame); |
130 main_frame->executeScript( | 133 main_frame->executeScript( |
131 blink::WebString( | 134 blink::WebString( |
132 "document.body.removeChild(document.getElementById('frame1'));")); | 135 "document.body.removeChild(document.getElementById('frame1'));")); |
133 } | 136 } |
134 | 137 |
135 bool StartTestServer() { | |
136 CHECK(!embedded_test_server_); | |
137 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer()); | |
138 embedded_test_server_->RegisterRequestHandler( | |
139 base::Bind(&PhishingDOMFeatureExtractorTest::HandleRequest, | |
140 base::Unretained(this))); | |
141 return embedded_test_server_->InitializeAndWaitUntilReady(); | |
142 } | |
143 | |
144 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 138 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
145 const net::test_server::HttpRequest& request) { | 139 const net::test_server::HttpRequest& request) { |
146 std::map<std::string, std::string>::const_iterator host_it = | 140 std::map<std::string, std::string>::const_iterator host_it = |
147 request.headers.find("Host"); | 141 request.headers.find("Host"); |
148 if (host_it == request.headers.end()) | 142 if (host_it == request.headers.end()) |
149 return scoped_ptr<net::test_server::HttpResponse>(); | 143 return scoped_ptr<net::test_server::HttpResponse>(); |
150 | 144 |
151 std::string url = | 145 std::string url = |
152 std::string("http://") + host_it->second + request.relative_url; | 146 std::string("http://") + host_it->second + request.relative_url; |
153 std::map<std::string, std::string>::const_iterator it = | 147 std::map<std::string, std::string>::const_iterator it = |
154 responses_.find(url); | 148 responses_.find(url); |
155 if (it == responses_.end()) | 149 if (it == responses_.end()) |
156 return scoped_ptr<net::test_server::HttpResponse>(); | 150 return scoped_ptr<net::test_server::HttpResponse>(); |
157 | 151 |
158 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 152 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
159 new net::test_server::BasicHttpResponse()); | 153 new net::test_server::BasicHttpResponse()); |
160 http_response->set_code(net::HTTP_OK); | 154 http_response->set_code(net::HTTP_OK); |
161 http_response->set_content_type("text/html"); | 155 http_response->set_content_type("text/html"); |
162 http_response->set_content(it->second); | 156 http_response->set_content(it->second); |
163 return http_response.Pass(); | 157 return http_response.Pass(); |
164 } | 158 } |
165 | 159 |
166 GURL GetURL(const std::string& host, const std::string& path) { | 160 GURL GetURL(const std::string& host, const std::string& path) { |
167 GURL::Replacements replace; | 161 GURL::Replacements replace; |
168 replace.SetHostStr(host); | 162 replace.SetHostStr(host); |
169 replace.SetPathStr(path); | 163 replace.SetPathStr(path); |
170 return embedded_test_server_->base_url().ReplaceComponents(replace); | 164 return embedded_test_server()->base_url().ReplaceComponents(replace); |
171 } | 165 } |
172 | 166 |
173 // Returns the URL that was loaded. | 167 // Returns the URL that was loaded. |
174 GURL LoadHtml(const std::string& host, const std::string& content) { | 168 GURL LoadHtml(const std::string& host, const std::string& content) { |
175 GURL url(GetURL(host, "")); | 169 GURL url(GetURL(host, "")); |
176 responses_[url.spec()] = content; | 170 responses_[url.spec()] = content; |
177 ui_test_utils::NavigateToURL(browser(), url); | 171 ui_test_utils::NavigateToURL(browser(), url); |
178 return url; | 172 return url; |
179 } | 173 } |
180 | 174 |
181 int32 render_view_routing_id_; | 175 int32 render_view_routing_id_; |
182 | 176 |
183 // Map of url -> response body for network requests from the renderer. | 177 // Map of url -> response body for network requests from the renderer. |
184 // Any urls not in this map are served a 404 error. | 178 // Any urls not in this map are served a 404 error. |
185 std::map<std::string, std::string> responses_; | 179 std::map<std::string, std::string> responses_; |
186 | 180 |
187 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; | |
188 MockFeatureExtractorClock clock_; | 181 MockFeatureExtractorClock clock_; |
189 scoped_ptr<PhishingDOMFeatureExtractor> extractor_; | 182 scoped_ptr<PhishingDOMFeatureExtractor> extractor_; |
190 bool success_; // holds the success value from ExtractFeatures | 183 bool success_; // holds the success value from ExtractFeatures |
191 base::WeakPtrFactory<PhishingDOMFeatureExtractorTest> weak_factory_; | 184 base::WeakPtrFactory<PhishingDOMFeatureExtractorTest> weak_factory_; |
192 }; | 185 }; |
193 | 186 |
194 IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest, FormFeatures) { | 187 IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest, FormFeatures) { |
195 // This test doesn't exercise the extraction timing. | 188 // This test doesn't exercise the extraction timing. |
196 EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(base::TimeTicks::Now())); | 189 EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(base::TimeTicks::Now())); |
197 | 190 |
198 FeatureMap expected_features; | 191 FeatureMap expected_features; |
199 expected_features.AddBooleanFeature(features::kPageHasForms); | 192 expected_features.AddBooleanFeature(features::kPageHasForms); |
200 expected_features.AddRealFeature(features::kPageActionOtherDomainFreq, 0.25); | 193 expected_features.AddRealFeature(features::kPageActionOtherDomainFreq, 0.25); |
201 expected_features.AddBooleanFeature(features::kPageHasTextInputs); | 194 expected_features.AddBooleanFeature(features::kPageHasTextInputs); |
202 expected_features.AddBooleanFeature(features::kPageHasCheckInputs); | 195 expected_features.AddBooleanFeature(features::kPageHasCheckInputs); |
203 expected_features.AddBooleanFeature(features::kPageActionURL + | 196 expected_features.AddBooleanFeature(features::kPageActionURL + |
204 std::string("http://cgi.host.com/submit")); | 197 std::string("http://cgi.host.com/submit")); |
205 expected_features.AddBooleanFeature(features::kPageActionURL + | 198 expected_features.AddBooleanFeature(features::kPageActionURL + |
206 std::string("http://other.com/")); | 199 std::string("http://other.com/")); |
207 expected_features.AddBooleanFeature(features::kPageActionURL + | 200 |
208 std::string("http://host.com:") + | 201 GURL url = embedded_test_server()->GetURL("/query"); |
209 base::UintToString(embedded_test_server_->port()) + | 202 GURL::Replacements replace_host; |
210 std::string("/query")); | 203 replace_host.SetHostStr("host.com"); |
| 204 expected_features.AddBooleanFeature( |
| 205 features::kPageActionURL + url.ReplaceComponents(replace_host).spec()); |
211 | 206 |
212 FeatureMap features; | 207 FeatureMap features; |
213 LoadHtml( | 208 LoadHtml( |
214 "host.com", | 209 "host.com", |
215 "<html><head><body>" | 210 "<html><head><body>" |
216 "<form action=\"query\"><input type=text><input type=checkbox></form>" | 211 "<form action=\"query\"><input type=text><input type=checkbox></form>" |
217 "<form action=\"http://cgi.host.com/submit\"></form>" | 212 "<form action=\"http://cgi.host.com/submit\"></form>" |
218 "<form action=\"http://other.com/\"></form>" | 213 "<form action=\"http://other.com/\"></form>" |
219 "<form action=\"query\"></form>" | 214 "<form action=\"query\"></form>" |
220 "<form></form></body></html>"); | 215 "<form></form></body></html>"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 "</body></html"); | 269 "</body></html"); |
275 ASSERT_TRUE(ExtractFeatures(&features)); | 270 ASSERT_TRUE(ExtractFeatures(&features)); |
276 ExpectFeatureMapsAreEqual(features, expected_features); | 271 ExpectFeatureMapsAreEqual(features, expected_features); |
277 | 272 |
278 expected_features.Clear(); | 273 expected_features.Clear(); |
279 expected_features.AddRealFeature(features::kPageExternalLinksFreq, 0.25); | 274 expected_features.AddRealFeature(features::kPageExternalLinksFreq, 0.25); |
280 expected_features.AddRealFeature(features::kPageSecureLinksFreq, 0.5); | 275 expected_features.AddRealFeature(features::kPageSecureLinksFreq, 0.5); |
281 expected_features.AddBooleanFeature(features::kPageLinkDomain + | 276 expected_features.AddBooleanFeature(features::kPageLinkDomain + |
282 std::string("chromium.org")); | 277 std::string("chromium.org")); |
283 | 278 |
284 net::SpawnedTestServer https_server( | 279 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
285 net::SpawnedTestServer::TYPE_HTTPS, | 280 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
286 net::SpawnedTestServer::kLocalhost, | |
287 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
288 ASSERT_TRUE(https_server.Start()); | 281 ASSERT_TRUE(https_server.Start()); |
289 | 282 |
290 // The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs, | 283 // The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs, |
291 // so use a domain. | 284 // so use a domain. |
292 std::string url_str = "https://host.com:"; | 285 GURL url = https_server.GetURL("/safe_browsing/secure_link_features.html"); |
293 url_str += base::UintToString(https_server.host_port_pair().port()); | 286 GURL::Replacements replace_host; |
294 url_str += "/files/safe_browsing/secure_link_features.html"; | 287 replace_host.SetHostStr("host.com"); |
295 ui_test_utils::NavigateToURL(browser(), GURL(url_str)); | 288 ui_test_utils::NavigateToURL(browser(), url.ReplaceComponents(replace_host)); |
296 | 289 |
297 // Click through the certificate error interstitial. | 290 // Click through the certificate error interstitial. |
298 content::InterstitialPage* interstitial_page = | 291 content::InterstitialPage* interstitial_page = |
299 GetWebContents()->GetInterstitialPage(); | 292 GetWebContents()->GetInterstitialPage(); |
300 interstitial_page->Proceed(); | 293 interstitial_page->Proceed(); |
301 content::WaitForLoadStop(GetWebContents()); | 294 content::WaitForLoadStop(GetWebContents()); |
302 | 295 |
303 features.Clear(); | 296 features.Clear(); |
304 ASSERT_TRUE(ExtractFeatures(&features)); | 297 ASSERT_TRUE(ExtractFeatures(&features)); |
305 ExpectFeatureMapsAreEqual(features, expected_features); | 298 ExpectFeatureMapsAreEqual(features, expected_features); |
(...skipping 19 matching lines...) Expand all Loading... |
325 "<html><head><script></script><script></script></head></html>"); | 318 "<html><head><script></script><script></script></head></html>"); |
326 ASSERT_TRUE(ExtractFeatures(&features)); | 319 ASSERT_TRUE(ExtractFeatures(&features)); |
327 ExpectFeatureMapsAreEqual(features, expected_features); | 320 ExpectFeatureMapsAreEqual(features, expected_features); |
328 | 321 |
329 expected_features.Clear(); | 322 expected_features.Clear(); |
330 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTOne); | 323 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTOne); |
331 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTSix); | 324 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTSix); |
332 expected_features.AddRealFeature(features::kPageImgOtherDomainFreq, 0.5); | 325 expected_features.AddRealFeature(features::kPageImgOtherDomainFreq, 0.5); |
333 | 326 |
334 features.Clear(); | 327 features.Clear(); |
335 net::SpawnedTestServer https_server( | 328 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
336 net::SpawnedTestServer::TYPE_HTTPS, | 329 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
337 net::SpawnedTestServer::kLocalhost, | |
338 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
339 ASSERT_TRUE(https_server.Start()); | 330 ASSERT_TRUE(https_server.Start()); |
340 | 331 |
341 // The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs, | 332 // The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs, |
342 // so use a domain. | 333 // so use a domain. |
343 std::string url_str = "https://host.com:"; | 334 GURL url = embedded_test_server()->GetURL( |
344 url_str += base::UintToString(https_server.host_port_pair().port()); | 335 "/safe_browsing/secure_script_and_image.html"); |
345 url_str += "/files/safe_browsing/secure_script_and_image.html"; | 336 GURL::Replacements replace_host; |
346 ui_test_utils::NavigateToURL(browser(), GURL(url_str)); | 337 replace_host.SetHostStr("host.com"); |
| 338 ui_test_utils::NavigateToURL(browser(), url.ReplaceComponents(replace_host)); |
347 | 339 |
348 // Click through the certificate error interstitial. | 340 // Click through the certificate error interstitial. |
349 content::InterstitialPage* interstitial_page = | 341 content::InterstitialPage* interstitial_page = |
350 GetWebContents()->GetInterstitialPage(); | 342 GetWebContents()->GetInterstitialPage(); |
351 interstitial_page->Proceed(); | 343 interstitial_page->Proceed(); |
352 content::WaitForLoadStop(GetWebContents()); | 344 content::WaitForLoadStop(GetWebContents()); |
353 | 345 |
354 ASSERT_TRUE(ExtractFeatures(&features)); | 346 ASSERT_TRUE(ExtractFeatures(&features)); |
355 ExpectFeatureMapsAreEqual(features, expected_features); | 347 ExpectFeatureMapsAreEqual(features, expected_features); |
356 } | 348 } |
357 | 349 |
358 IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest, SubFrames) { | 350 IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest, SubFrames) { |
359 // This test doesn't exercise the extraction timing. | 351 // This test doesn't exercise the extraction timing. |
360 EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(base::TimeTicks::Now())); | 352 EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(base::TimeTicks::Now())); |
361 | 353 |
362 // Test that features are aggregated across all frames. | 354 // Test that features are aggregated across all frames. |
363 | 355 |
364 std::string port = base::UintToString(embedded_test_server_->port()); | |
365 responses_[GetURL("host2.com", "").spec()] = | 356 responses_[GetURL("host2.com", "").spec()] = |
366 "<html><head><script></script><body>" | 357 "<html><head><script></script><body>" |
367 "<form action=\"http://host4.com/\"><input type=checkbox></form>" | 358 "<form action=\"http://host4.com/\"><input type=checkbox></form>" |
368 "<form action=\"http://host2.com/submit\"></form>" | 359 "<form action=\"http://host2.com/submit\"></form>" |
369 "<a href=\"http://www.host2.com/home\">link</a>" | 360 "<a href=\"http://www.host2.com/home\">link</a>" |
370 "<iframe src=\"nested.html\"></iframe>" | 361 "<iframe src=\"nested.html\"></iframe>" |
371 "<body></html>"; | 362 "<body></html>"; |
372 | 363 |
373 responses_[GetURL("host2.com", "nested.html").spec()] = | 364 responses_[GetURL("host2.com", "nested.html").spec()] = |
374 "<html><body><input type=password>" | 365 "<html><body><input type=password>" |
(...skipping 20 matching lines...) Expand all Loading... |
395 std::string("host4.com")); | 386 std::string("host4.com")); |
396 expected_features.AddRealFeature(features::kPageSecureLinksFreq, 0.25); | 387 expected_features.AddRealFeature(features::kPageSecureLinksFreq, 0.25); |
397 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTOne); | 388 expected_features.AddBooleanFeature(features::kPageNumScriptTagsGTOne); |
398 expected_features.AddRealFeature(features::kPageImgOtherDomainFreq, 1.0); | 389 expected_features.AddRealFeature(features::kPageImgOtherDomainFreq, 1.0); |
399 expected_features.AddBooleanFeature(features::kPageActionURL + | 390 expected_features.AddBooleanFeature(features::kPageActionURL + |
400 std::string("http://host2.com/submit")); | 391 std::string("http://host2.com/submit")); |
401 expected_features.AddBooleanFeature(features::kPageActionURL + | 392 expected_features.AddBooleanFeature(features::kPageActionURL + |
402 std::string("http://host4.com/")); | 393 std::string("http://host4.com/")); |
403 | 394 |
404 FeatureMap features; | 395 FeatureMap features; |
| 396 GURL url = embedded_test_server()->GetURL("/"); |
| 397 GURL::Replacements replace_host; |
| 398 replace_host.SetHostStr("host2.com"); |
| 399 GURL::Replacements replace_host_2; |
| 400 replace_host_2.SetHostStr("host3.com"); |
| 401 |
405 std::string html( | 402 std::string html( |
406 "<html><body><input type=text><a href=\"info.html\">link</a>" | 403 "<html><body><input type=text><a href=\"info.html\">link</a>" |
407 "<iframe src=\"http://host2.com:"); | 404 "<iframe src=\""); |
408 html += port; | 405 html += url.ReplaceComponents(replace_host).spec(); |
409 html += std::string( | 406 html += std::string("\"></iframe><iframe src=\""); |
410 "/\"></iframe>" | 407 html += url.ReplaceComponents(replace_host_2).spec(); |
411 "<iframe src=\"http://host3.com:"); | 408 html += std::string("\"></iframe></body></html>"); |
412 html += port; | |
413 html += std::string("/\"></iframe></body></html>"); | |
414 | 409 |
415 LoadHtml("host.com", html); | 410 LoadHtml("host.com", html); |
416 ASSERT_TRUE(ExtractFeatures(&features)); | 411 ASSERT_TRUE(ExtractFeatures(&features)); |
417 ExpectFeatureMapsAreEqual(features, expected_features); | 412 ExpectFeatureMapsAreEqual(features, expected_features); |
418 } | 413 } |
419 | 414 |
420 // Test flakes with LSAN enabled. See http://crbug.com/373155. | 415 // Test flakes with LSAN enabled. See http://crbug.com/373155. |
421 #if defined(LEAK_SANITIZER) | 416 #if defined(LEAK_SANITIZER) |
422 #define MAYBE_Continuation DISABLED_Continuation | 417 #define MAYBE_Continuation DISABLED_Continuation |
423 #else | 418 #else |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // Time check after resuming iteration for the third chunk. | 461 // Time check after resuming iteration for the third chunk. |
467 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(48))) | 462 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(48))) |
468 // Time check after the last 10 elements. | 463 // Time check after the last 10 elements. |
469 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(54))) | 464 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(54))) |
470 // A final time check for the histograms. | 465 // A final time check for the histograms. |
471 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(56))); | 466 .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(56))); |
472 | 467 |
473 FeatureMap expected_features; | 468 FeatureMap expected_features; |
474 expected_features.AddBooleanFeature(features::kPageHasForms); | 469 expected_features.AddBooleanFeature(features::kPageHasForms); |
475 expected_features.AddRealFeature(features::kPageActionOtherDomainFreq, 0.5); | 470 expected_features.AddRealFeature(features::kPageActionOtherDomainFreq, 0.5); |
476 expected_features.AddBooleanFeature(features::kPageActionURL + | 471 GURL url = embedded_test_server()->GetURL("/ondomain"); |
477 std::string("http://host.com:") + | 472 GURL::Replacements replace_host; |
478 base::UintToString(embedded_test_server_->port()) + | 473 replace_host.SetHostStr("host.com"); |
479 std::string("/ondomain")); | 474 expected_features.AddBooleanFeature( |
| 475 features::kPageActionURL + url.ReplaceComponents(replace_host).spec()); |
480 expected_features.AddBooleanFeature(features::kPageActionURL + | 476 expected_features.AddBooleanFeature(features::kPageActionURL + |
481 std::string("http://host2.com/")); | 477 std::string("http://host2.com/")); |
482 | 478 |
483 FeatureMap features; | 479 FeatureMap features; |
484 LoadHtml("host.com", response); | 480 LoadHtml("host.com", response); |
485 ASSERT_TRUE(ExtractFeatures(&features)); | 481 ASSERT_TRUE(ExtractFeatures(&features)); |
486 ExpectFeatureMapsAreEqual(features, expected_features); | 482 ExpectFeatureMapsAreEqual(features, expected_features); |
487 // Make sure none of the mock expectations carry over to the next test. | 483 // Make sure none of the mock expectations carry over to the next test. |
488 ::testing::Mock::VerifyAndClearExpectations(&clock_); | 484 ::testing::Mock::VerifyAndClearExpectations(&clock_); |
489 | 485 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 LoadHtml( | 543 LoadHtml( |
548 "host.com", | 544 "host.com", |
549 "<html><head></head><body>" | 545 "<html><head></head><body>" |
550 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" | 546 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" |
551 "<form></form></body></html>"); | 547 "<form></form></body></html>"); |
552 ASSERT_TRUE(ExtractFeatures(&features)); | 548 ASSERT_TRUE(ExtractFeatures(&features)); |
553 ExpectFeatureMapsAreEqual(features, expected_features); | 549 ExpectFeatureMapsAreEqual(features, expected_features); |
554 } | 550 } |
555 | 551 |
556 } // namespace safe_browsing | 552 } // namespace safe_browsing |
OLD | NEW |