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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 6611023: The optional Malware Details also collects HTTP cache information. See design... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This test creates a fake safebrowsing service, where we can inject 5 // This test creates a fake safebrowsing service, where we can inject
6 // malware and phishing urls. It then uses a real browser to go to 6 // malware and phishing urls. It then uses a real browser to go to
7 // these urls, and sends "goback" or "proceed" commands and verifies 7 // these urls, and sends "goback" or "proceed" commands and verifies
8 // they work. 8 // they work.
9 9
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 check.url.reset(new GURL(gurl)); 52 check.url.reset(new GURL(gurl));
53 check.client = client; 53 check.client = client;
54 check.result = badurls[gurl.spec()]; 54 check.result = badurls[gurl.spec()];
55 client->OnSafeBrowsingResult(check); 55 client->OnSafeBrowsingResult(check);
56 } 56 }
57 57
58 void AddURLResult(const GURL& url, UrlCheckResult checkresult) { 58 void AddURLResult(const GURL& url, UrlCheckResult checkresult) {
59 badurls[url.spec()] = checkresult; 59 badurls[url.spec()] = checkresult;
60 } 60 }
61 61
62 virtual void ReportMalwareDetails(scoped_refptr<MalwareDetails> details) { 62 virtual void OnReportReady(scoped_refptr<MalwareDetails> report) {
63 details_.push_back(details); 63 details_.push_back(report);
64 // Notify the UI thread, that we got a report. 64 // Notify the UI thread that we got a report.
65 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 65 BrowserThread::PostTask(
66 NewRunnableMethod(this, 66 BrowserThread::UI, FROM_HERE,
67 &FakeSafeBrowsingService::OnMalwareDetailsDone)); 67 NewRunnableMethod(this,
68 &FakeSafeBrowsingService::OnMalwareDetailsDone));
68 } 69 }
69 70
70 void OnMalwareDetailsDone() { 71 void OnMalwareDetailsDone() {
71 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 72 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 MessageLoopForUI::current()->Quit(); 73 MessageLoopForUI::current()->Quit();
73 } 74 }
74 75
75 std::list<scoped_refptr<MalwareDetails> >* GetDetails() { 76 std::vector<scoped_refptr<MalwareDetails> >* GetDetails() {
76 return &details_; 77 return &details_;
77 } 78 }
78 79
79 std::list<scoped_refptr<MalwareDetails> > details_; 80 std::vector<scoped_refptr<MalwareDetails> > details_;
80 81
81 private: 82 private:
82 base::hash_map<std::string, UrlCheckResult> badurls; 83 base::hash_map<std::string, UrlCheckResult> badurls;
83 }; 84 };
84 85
85 // Factory that creates FakeSafeBrowsingService instances. 86 // Factory that creates FakeSafeBrowsingService instances.
86 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { 87 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory {
87 public: 88 public:
88 TestSafeBrowsingServiceFactory() { } 89 TestSafeBrowsingServiceFactory() { }
89 virtual ~TestSafeBrowsingServiceFactory() { } 90 virtual ~TestSafeBrowsingServiceFactory() { }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 130 }
130 131
131 void set_got_dom(bool got_dom) { 132 void set_got_dom(bool got_dom) {
132 got_dom_ = got_dom; 133 got_dom_ = got_dom;
133 } 134 }
134 135
135 void set_waiting(bool waiting) { 136 void set_waiting(bool waiting) {
136 waiting_ = waiting; 137 waiting_ = waiting;
137 } 138 }
138 139
140 safe_browsing::ClientMalwareReportRequest* get_report() {
141 return report_.get();
142 }
143
139 private: 144 private:
140 // Some logic to figure out if we should wait for the dom details or not. 145 // Some logic to figure out if we should wait for the dom details or not.
141 // These variables should only be accessed in the UI thread. 146 // These variables should only be accessed in the UI thread.
142 bool got_dom_; 147 bool got_dom_;
143 bool waiting_; 148 bool waiting_;
144 149
145 }; 150 };
146 151
147 class TestMalwareDetailsFactory : public MalwareDetailsFactory { 152 class TestMalwareDetailsFactory : public MalwareDetailsFactory {
148 public: 153 public:
149 TestMalwareDetailsFactory() { } 154 TestMalwareDetailsFactory() { }
150 virtual ~TestMalwareDetailsFactory() { } 155 virtual ~TestMalwareDetailsFactory() { }
151 156
152 virtual MalwareDetails* CreateMalwareDetails( 157 virtual MalwareDetails* CreateMalwareDetails(
153 TabContents* tab_contents, 158 TabContents* tab_contents,
154 const SafeBrowsingService::UnsafeResource& unsafe_resource) { 159 const SafeBrowsingService::UnsafeResource& unsafe_resource) {
155 details_ = new FakeMalwareDetails(tab_contents, unsafe_resource); 160 details_ = new FakeMalwareDetails(tab_contents, unsafe_resource);
156 return details_; 161 return details_;
157 } 162 }
158 163
159 FakeMalwareDetails* get_details() { 164 FakeMalwareDetails* get_details() {
160 return details_; 165 return details_;
161 } 166 }
162 167
163 private: 168 private:
164 FakeMalwareDetails* details_; 169 FakeMalwareDetails* details_;
165 }; 170 };
166 171
172 // A SafeBrowingBlockingPage class that lets us wait until it's hidden.
173 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage {
174 public:
175 TestSafeBrowsingBlockingPage(SafeBrowsingService* service,
176 TabContents* tab_contents,
177 const UnsafeResourceList& unsafe_resources)
178 : SafeBrowsingBlockingPage(service, tab_contents, unsafe_resources) {
179 wait_for_delete_ = false;
180 }
181
182 ~TestSafeBrowsingBlockingPage() {
183 if (wait_for_delete_) {
184 // Notify that we are gone
185 MessageLoopForUI::current()->Quit();
186 }
187 }
188
189 void set_wait_for_delete() {
190 wait_for_delete_ = true;
191 }
192
193 private:
194 bool wait_for_delete_;
195 };
196
197 class TestSafeBrowsingBlockingPageFactory
198 : public SafeBrowsingBlockingPageFactory {
199 public:
200 TestSafeBrowsingBlockingPageFactory() { }
201 ~TestSafeBrowsingBlockingPageFactory() { }
202
203 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
204 SafeBrowsingService* service,
205 TabContents* tab_contents,
206 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) {
207 return new TestSafeBrowsingBlockingPage(service, tab_contents,
208 unsafe_resources);
209 }
210 };
211
167 // Tests the safe browsing blocking page in a browser. 212 // Tests the safe browsing blocking page in a browser.
168 class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, 213 class SafeBrowsingBlockingPageTest : public InProcessBrowserTest,
169 public SafeBrowsingService::Client { 214 public SafeBrowsingService::Client {
170 public: 215 public:
171 SafeBrowsingBlockingPageTest() { 216 SafeBrowsingBlockingPageTest() {
172 } 217 }
173 218
174 virtual void SetUp() { 219 virtual void SetUp() {
175 SafeBrowsingService::RegisterFactory(&factory_); 220 SafeBrowsingService::RegisterFactory(&factory_);
221 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_);
176 MalwareDetails::RegisterFactory(&details_factory_); 222 MalwareDetails::RegisterFactory(&details_factory_);
177 InProcessBrowserTest::SetUp(); 223 InProcessBrowserTest::SetUp();
178 } 224 }
179 225
180 virtual void TearDown() { 226 virtual void TearDown() {
181 InProcessBrowserTest::TearDown(); 227 InProcessBrowserTest::TearDown();
228 SafeBrowsingBlockingPage::RegisterFactory(NULL);
182 SafeBrowsingService::RegisterFactory(NULL); 229 SafeBrowsingService::RegisterFactory(NULL);
183 MalwareDetails::RegisterFactory(NULL); 230 MalwareDetails::RegisterFactory(NULL);
184 } 231 }
185 232
186 virtual void SetUpInProcessBrowserTestFixture() { 233 virtual void SetUpInProcessBrowserTestFixture() {
187 ASSERT_TRUE(test_server()->Start()); 234 ASSERT_TRUE(test_server()->Start());
188 } 235 }
189 236
190 // SafeBrowsingService::Client implementation. 237 // SafeBrowsingService::Client implementation.
191 virtual void OnSafeBrowsingResult( 238 virtual void OnSafeBrowsingResult(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 276 }
230 277
231 void ProceedThroughInterstitial() { 278 void ProceedThroughInterstitial() {
232 TabContents* contents = browser()->GetSelectedTabContents(); 279 TabContents* contents = browser()->GetSelectedTabContents();
233 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( 280 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage(
234 contents); 281 contents);
235 ASSERT_TRUE(interstitial_page); 282 ASSERT_TRUE(interstitial_page);
236 interstitial_page->Proceed(); 283 interstitial_page->Proceed();
237 } 284 }
238 285
239 void AssertNoInterstitial() { 286 void AssertNoInterstitial(bool wait_for_delete) {
240 // ui_test_utils::RunAllPendingInMessageLoop();
241 TabContents* contents = browser()->GetSelectedTabContents(); 287 TabContents* contents = browser()->GetSelectedTabContents();
242 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( 288
243 contents); 289 if (contents->showing_interstitial_page() && wait_for_delete) {
244 ASSERT_FALSE(interstitial_page); 290 // We'll get notified when the interstitial is deleted.
291 static_cast<TestSafeBrowsingBlockingPage*>(
292 contents->interstitial_page())->set_wait_for_delete();
293 ui_test_utils::RunMessageLoop();
294 }
295
296 // Can't use InterstitialPage::GetInterstitialPage() because that
297 // gets updated after the TestSafeBrowsingBlockingPage destructor
298 ASSERT_FALSE(contents->showing_interstitial_page());
245 } 299 }
246 300
247 void WaitForNavigation() { 301 void WaitForNavigation() {
248 NavigationController* controller = 302 NavigationController* controller =
249 &browser()->GetSelectedTabContents()->controller(); 303 &browser()->GetSelectedTabContents()->controller();
250 ui_test_utils::WaitForNavigation(controller); 304 ui_test_utils::WaitForNavigation(controller);
251 } 305 }
252 306
253 void AssertReportSent() { 307 void AssertReportSent() {
254 // When a report is scheduled in the IO thread we should get notified. 308 // When a report is scheduled in the IO thread we should get notified.
255 ui_test_utils::RunMessageLoop(); 309 ui_test_utils::RunMessageLoop();
256 310
257 FakeSafeBrowsingService* service = 311 FakeSafeBrowsingService* service =
258 static_cast<FakeSafeBrowsingService*>( 312 static_cast<FakeSafeBrowsingService*>(
259 g_browser_process->resource_dispatcher_host()-> 313 g_browser_process->resource_dispatcher_host()->
260 safe_browsing_service()); 314 safe_browsing_service());
261 ASSERT_EQ(1u, service->GetDetails()->size()); 315 ASSERT_EQ(1u, service->GetDetails()->size());
316
317 // Verify the report is complete.
318 FakeMalwareDetails* details =
319 static_cast<FakeMalwareDetails*>(service->GetDetails()->at(0).get());
320 EXPECT_TRUE(details->get_report()->complete());
262 } 321 }
263 322
264 protected: 323 protected:
265 TestMalwareDetailsFactory details_factory_; 324 TestMalwareDetailsFactory details_factory_;
266 325
267 private: 326 private:
268 TestSafeBrowsingServiceFactory factory_; 327 TestSafeBrowsingServiceFactory factory_;
328 TestSafeBrowsingBlockingPageFactory blocking_page_factory_;
269 329
270 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest); 330 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest);
271 }; 331 };
272 332
273 namespace { 333 namespace {
274 334
275 const char kEmptyPage[] = "files/empty.html"; 335 const char kEmptyPage[] = "files/empty.html";
276 const char kMalwarePage[] = "files/safe_browsing/malware.html"; 336 const char kMalwarePage[] = "files/safe_browsing/malware.html";
277 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html"; 337 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html";
278 338
279 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { 339 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) {
280 GURL url = test_server()->GetURL(kEmptyPage); 340 GURL url = test_server()->GetURL(kEmptyPage);
281 AddURLResult(url, SafeBrowsingService::URL_MALWARE); 341 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
282 342
283 ui_test_utils::NavigateToURL(browser(), url); 343 ui_test_utils::NavigateToURL(browser(), url);
284 344
285 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" 345 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back"
286 AssertNoInterstitial(); // Assert the interstitial is gone 346 AssertNoInterstitial(false); // Assert the interstitial is gone
287 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank" 347 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank"
288 browser()->GetSelectedTabContents()->GetURL()); 348 browser()->GetSelectedTabContents()->GetURL());
289 } 349 }
290 350
291 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { 351 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) {
292 GURL url = test_server()->GetURL(kEmptyPage); 352 GURL url = test_server()->GetURL(kEmptyPage);
293 AddURLResult(url, SafeBrowsingService::URL_MALWARE); 353 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
294 354
295 ui_test_utils::NavigateToURL(browser(), url); 355 ui_test_utils::NavigateToURL(browser(), url);
296 356
297 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" 357 SendCommand("\"proceed\""); // Simulate the user clicking "proceed"
298 WaitForNavigation(); // Wait until we finish the navigation. 358 WaitForNavigation(); // Wait until we finish the navigation.
299 AssertNoInterstitial(); // Assert the interstitial is gone. 359 AssertNoInterstitial(true); // Assert the interstitial is gone.
300 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 360 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
301 } 361 }
302 362
303 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { 363 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) {
304 GURL url = test_server()->GetURL(kEmptyPage); 364 GURL url = test_server()->GetURL(kEmptyPage);
305 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 365 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
306 366
307 ui_test_utils::NavigateToURL(browser(), url); 367 ui_test_utils::NavigateToURL(browser(), url);
308 368
309 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" 369 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed"
310 AssertNoInterstitial(); // Assert the interstitial is gone 370 AssertNoInterstitial(false); // Assert the interstitial is gone
311 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // We are back to "about:blank". 371 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // We are back to "about:blank".
312 browser()->GetSelectedTabContents()->GetURL()); 372 browser()->GetSelectedTabContents()->GetURL());
313 } 373 }
314 374
315 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { 375 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) {
316 GURL url = test_server()->GetURL(kEmptyPage); 376 GURL url = test_server()->GetURL(kEmptyPage);
317 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 377 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
318 378
319 ui_test_utils::NavigateToURL(browser(), url); 379 ui_test_utils::NavigateToURL(browser(), url);
320 380
321 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". 381 SendCommand("\"proceed\""); // Simulate the user clicking "proceed".
322 WaitForNavigation(); // Wait until we finish the navigation. 382 WaitForNavigation(); // Wait until we finish the navigation.
323 AssertNoInterstitial(); // Assert the interstitial is gone 383 AssertNoInterstitial(true); // Assert the interstitial is gone
324 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 384 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
325 } 385 }
326 386
327 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { 387 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) {
328 GURL url = test_server()->GetURL(kEmptyPage); 388 GURL url = test_server()->GetURL(kEmptyPage);
329 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 389 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
330 390
331 ui_test_utils::NavigateToURL(browser(), url); 391 ui_test_utils::NavigateToURL(browser(), url);
332 392
333 SendCommand("\"reportError\""); // Simulate the user clicking "report error" 393 SendCommand("\"reportError\""); // Simulate the user clicking "report error"
334 WaitForNavigation(); // Wait until we finish the navigation. 394 WaitForNavigation(); // Wait until we finish the navigation.
335 AssertNoInterstitial(); // Assert the interstitial is gone 395 AssertNoInterstitial(false); // Assert the interstitial is gone
336 396
337 // We are in the error reporting page. 397 // We are in the error reporting page.
338 EXPECT_EQ("/safebrowsing/report_error/", 398 EXPECT_EQ("/safebrowsing/report_error/",
339 browser()->GetSelectedTabContents()->GetURL().path()); 399 browser()->GetSelectedTabContents()->GetURL().path());
340 } 400 }
341 401
342 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingLearnMore) { 402 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingLearnMore) {
343 GURL url = test_server()->GetURL(kEmptyPage); 403 GURL url = test_server()->GetURL(kEmptyPage);
344 AddURLResult(url, SafeBrowsingService::URL_PHISHING); 404 AddURLResult(url, SafeBrowsingService::URL_PHISHING);
345 405
346 ui_test_utils::NavigateToURL(browser(), url); 406 ui_test_utils::NavigateToURL(browser(), url);
347 407
348 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" 408 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more"
349 WaitForNavigation(); // Wait until we finish the navigation. 409 WaitForNavigation(); // Wait until we finish the navigation.
350 AssertNoInterstitial(); // Assert the interstitial is gone 410 AssertNoInterstitial(false); // Assert the interstitial is gone
351 411
352 // We are in the help page. 412 // We are in the help page.
353 EXPECT_EQ("/support/bin/answer.py", 413 EXPECT_EQ("/support/bin/answer.py",
354 browser()->GetSelectedTabContents()->GetURL().path()); 414 browser()->GetSelectedTabContents()->GetURL().path());
355 } 415 }
356 416
357 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { 417 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) {
358 GURL url = test_server()->GetURL(kMalwarePage); 418 GURL url = test_server()->GetURL(kMalwarePage);
359 GURL iframe_url = test_server()->GetURL(kMalwareIframe); 419 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
360 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); 420 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
361 421
362 ui_test_utils::NavigateToURL(browser(), url); 422 ui_test_utils::NavigateToURL(browser(), url);
363 423
364 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" 424 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back"
365 AssertNoInterstitial(); // Assert the interstitial is gone 425 AssertNoInterstitial(false); // Assert the interstitial is gone
366 426
367 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank" 427 EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank"
368 browser()->GetSelectedTabContents()->GetURL()); 428 browser()->GetSelectedTabContents()->GetURL());
369 } 429 }
370 430
371 // Crashy, http://crbug.com/68834. 431 // Crashy, http://crbug.com/68834.
372 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 432 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
373 DISABLED_MalwareIframeProceed) { 433 DISABLED_MalwareIframeProceed) {
374 GURL url = test_server()->GetURL(kMalwarePage); 434 GURL url = test_server()->GetURL(kMalwarePage);
375 GURL iframe_url = test_server()->GetURL(kMalwareIframe); 435 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
376 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); 436 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
377 437
378 ui_test_utils::NavigateToURL(browser(), url); 438 ui_test_utils::NavigateToURL(browser(), url);
379 439
380 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" 440 SendCommand("\"proceed\""); // Simulate the user clicking "proceed"
381 AssertNoInterstitial(); // Assert the interstitial is gone 441 AssertNoInterstitial(true); // Assert the interstitial is gone
382 442
383 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 443 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
384 } 444 }
385 445
386 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, 446 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
387 MalwareIframeReportDetails) { 447 MalwareIframeReportDetails) {
388 GURL url = test_server()->GetURL(kMalwarePage); 448 GURL url = test_server()->GetURL(kMalwarePage);
389 GURL iframe_url = test_server()->GetURL(kMalwareIframe); 449 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
390 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); 450 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
391 451
392 ui_test_utils::NavigateToURL(browser(), url); 452 ui_test_utils::NavigateToURL(browser(), url);
393 453
394 // If the DOM details from renderer did not already return, wait for them. 454 // If the DOM details from renderer did not already return, wait for them.
395 if (!details_factory_.get_details()->got_dom()) { 455 if (!details_factory_.get_details()->got_dom()) {
396 // This condition might not trigger normally, but if you add a 456 // This condition might not trigger normally, but if you add a
397 // sleep(1) in malware_dom_details it triggers :). 457 // sleep(1) in malware_dom_details it triggers :).
398 details_factory_.get_details()->set_waiting(true); 458 details_factory_.get_details()->set_waiting(true);
399 LOG(INFO) << "Waiting for dom details."; 459 LOG(INFO) << "Waiting for dom details.";
400 ui_test_utils::RunMessageLoop(); 460 ui_test_utils::RunMessageLoop();
401 } else { 461 } else {
402 LOG(INFO) << "Already got the dom details."; 462 LOG(INFO) << "Already got the dom details.";
403 } 463 }
404 464
405 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. 465 SendCommand("\"doReport\""); // Simulate the user checking the checkbox.
406 EXPECT_TRUE(browser()->GetProfile()->GetPrefs()->GetBoolean( 466 EXPECT_TRUE(browser()->GetProfile()->GetPrefs()->GetBoolean(
407 prefs::kSafeBrowsingReportingEnabled)); 467 prefs::kSafeBrowsingReportingEnabled));
408 468
409 SendCommand("\"proceed\""); // Simulate the user clicking "back" 469 SendCommand("\"proceed\""); // Simulate the user clicking "back"
410 AssertNoInterstitial(); // Assert the interstitial is gone 470 AssertNoInterstitial(true); // Assert the interstitial is gone
411 471
412 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); 472 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
413 AssertReportSent(); 473 AssertReportSent();
414 } 474 }
415 475
416 } // namespace 476 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698