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 // 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 "base/bind.h" | 10 #include "base/bind.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/safe_browsing/malware_details.h" | 14 #include "chrome/browser/safe_browsing/malware_details.h" |
15 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/browser/interstitial_page.h" | 24 #include "content/public/browser/interstitial_page.h" |
24 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_contents_view.h" | 28 #include "content/public/browser/web_contents_view.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 SafeBrowsingService::UrlCheckResult checkresult) { | 255 SafeBrowsingService::UrlCheckResult checkresult) { |
255 FakeSafeBrowsingService* service = | 256 FakeSafeBrowsingService* service = |
256 static_cast<FakeSafeBrowsingService*>( | 257 static_cast<FakeSafeBrowsingService*>( |
257 g_browser_process->safe_browsing_service()); | 258 g_browser_process->safe_browsing_service()); |
258 | 259 |
259 ASSERT_TRUE(service); | 260 ASSERT_TRUE(service); |
260 service->AddURLResult(url, checkresult); | 261 service->AddURLResult(url, checkresult); |
261 } | 262 } |
262 | 263 |
263 void SendCommand(const std::string& command) { | 264 void SendCommand(const std::string& command) { |
264 WebContents* contents = browser()->GetActiveWebContents(); | 265 WebContents* contents = chrome::GetActiveWebContents(browser()); |
265 // We use InterstitialPage::GetInterstitialPage(tab) instead of | 266 // We use InterstitialPage::GetInterstitialPage(tab) instead of |
266 // tab->GetInterstitialPage() because the tab doesn't have a pointer | 267 // tab->GetInterstitialPage() because the tab doesn't have a pointer |
267 // to its interstital page until it gets a command from the renderer | 268 // to its interstital page until it gets a command from the renderer |
268 // that it has indeed displayed it -- and this sometimes happens after | 269 // that it has indeed displayed it -- and this sometimes happens after |
269 // NavigateToURL returns. | 270 // NavigateToURL returns. |
270 SafeBrowsingBlockingPage* interstitial_page = | 271 SafeBrowsingBlockingPage* interstitial_page = |
271 static_cast<SafeBrowsingBlockingPage*>( | 272 static_cast<SafeBrowsingBlockingPage*>( |
272 InterstitialPage::GetInterstitialPage(contents)-> | 273 InterstitialPage::GetInterstitialPage(contents)-> |
273 GetDelegateForTesting()); | 274 GetDelegateForTesting()); |
274 ASSERT_TRUE(interstitial_page); | 275 ASSERT_TRUE(interstitial_page); |
275 interstitial_page->CommandReceived(command); | 276 interstitial_page->CommandReceived(command); |
276 } | 277 } |
277 | 278 |
278 void DontProceedThroughInterstitial() { | 279 void DontProceedThroughInterstitial() { |
279 WebContents* contents = browser()->GetActiveWebContents(); | 280 WebContents* contents = chrome::GetActiveWebContents(browser()); |
280 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( | 281 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( |
281 contents); | 282 contents); |
282 ASSERT_TRUE(interstitial_page); | 283 ASSERT_TRUE(interstitial_page); |
283 interstitial_page->DontProceed(); | 284 interstitial_page->DontProceed(); |
284 } | 285 } |
285 | 286 |
286 void ProceedThroughInterstitial() { | 287 void ProceedThroughInterstitial() { |
287 WebContents* contents = browser()->GetActiveWebContents(); | 288 WebContents* contents = chrome::GetActiveWebContents(browser()); |
288 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( | 289 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( |
289 contents); | 290 contents); |
290 ASSERT_TRUE(interstitial_page); | 291 ASSERT_TRUE(interstitial_page); |
291 interstitial_page->Proceed(); | 292 interstitial_page->Proceed(); |
292 } | 293 } |
293 | 294 |
294 void AssertNoInterstitial(bool wait_for_delete) { | 295 void AssertNoInterstitial(bool wait_for_delete) { |
295 WebContents* contents = browser()->GetActiveWebContents(); | 296 WebContents* contents = chrome::GetActiveWebContents(browser()); |
296 | 297 |
297 if (contents->ShowingInterstitialPage() && wait_for_delete) { | 298 if (contents->ShowingInterstitialPage() && wait_for_delete) { |
298 // We'll get notified when the interstitial is deleted. | 299 // We'll get notified when the interstitial is deleted. |
299 TestSafeBrowsingBlockingPage* page = | 300 TestSafeBrowsingBlockingPage* page = |
300 static_cast<TestSafeBrowsingBlockingPage*>( | 301 static_cast<TestSafeBrowsingBlockingPage*>( |
301 contents->GetInterstitialPage()->GetDelegateForTesting()); | 302 contents->GetInterstitialPage()->GetDelegateForTesting()); |
302 page->WaitForDelete(); | 303 page->WaitForDelete(); |
303 } | 304 } |
304 | 305 |
305 // Can't use InterstitialPage::GetInterstitialPage() because that | 306 // Can't use InterstitialPage::GetInterstitialPage() because that |
306 // gets updated after the TestSafeBrowsingBlockingPage destructor | 307 // gets updated after the TestSafeBrowsingBlockingPage destructor |
307 ASSERT_FALSE(contents->ShowingInterstitialPage()); | 308 ASSERT_FALSE(contents->ShowingInterstitialPage()); |
308 } | 309 } |
309 | 310 |
310 bool YesInterstitial() { | 311 bool YesInterstitial() { |
311 WebContents* contents = browser()->GetActiveWebContents(); | 312 WebContents* contents = chrome::GetActiveWebContents(browser()); |
312 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( | 313 InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( |
313 contents); | 314 contents); |
314 return interstitial_page != NULL; | 315 return interstitial_page != NULL; |
315 } | 316 } |
316 | 317 |
317 void WaitForInterstitial() { | 318 void WaitForInterstitial() { |
318 WebContents* contents = browser()->GetActiveWebContents(); | 319 WebContents* contents = chrome::GetActiveWebContents(browser()); |
319 ui_test_utils::WindowedNotificationObserver interstitial_observer( | 320 ui_test_utils::WindowedNotificationObserver interstitial_observer( |
320 content::NOTIFICATION_INTERSTITIAL_ATTACHED, | 321 content::NOTIFICATION_INTERSTITIAL_ATTACHED, |
321 content::Source<WebContents>(contents)); | 322 content::Source<WebContents>(contents)); |
322 if (!InterstitialPage::GetInterstitialPage(contents)) | 323 if (!InterstitialPage::GetInterstitialPage(contents)) |
323 interstitial_observer.Wait(); | 324 interstitial_observer.Wait(); |
324 } | 325 } |
325 | 326 |
326 void AssertReportSent() { | 327 void AssertReportSent() { |
327 // When a report is scheduled in the IO thread we should get notified. | 328 // When a report is scheduled in the IO thread we should get notified. |
328 ui_test_utils::RunMessageLoop(); | 329 ui_test_utils::RunMessageLoop(); |
(...skipping 21 matching lines...) Expand all Loading... |
350 ui_test_utils::NavigateToURL(browser(), load_url); | 351 ui_test_utils::NavigateToURL(browser(), load_url); |
351 // Trigger the safe browsing interstitial page via a redirect in | 352 // Trigger the safe browsing interstitial page via a redirect in |
352 // "openWin()". | 353 // "openWin()". |
353 ui_test_utils::NavigateToURLWithDisposition( | 354 ui_test_utils::NavigateToURLWithDisposition( |
354 browser(), | 355 browser(), |
355 GURL("javascript:" + open_function + "()"), | 356 GURL("javascript:" + open_function + "()"), |
356 CURRENT_TAB, | 357 CURRENT_TAB, |
357 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 358 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
358 WaitForInterstitial(); | 359 WaitForInterstitial(); |
359 // Cancel the redirect request while interstitial page is open. | 360 // Cancel the redirect request while interstitial page is open. |
360 browser()->ActivateTabAt(0, true); | 361 chrome::ActivateTabAt(browser(), 0, true); |
361 ui_test_utils::NavigateToURLWithDisposition( | 362 ui_test_utils::NavigateToURLWithDisposition( |
362 browser(), | 363 browser(), |
363 GURL("javascript:stopWin()"), | 364 GURL("javascript:stopWin()"), |
364 CURRENT_TAB, | 365 CURRENT_TAB, |
365 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 366 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
366 browser()->ActivateTabAt(1, true); | 367 chrome::ActivateTabAt(browser(), 1, true); |
367 // Simulate the user clicking "proceed", there should be no crash. | 368 // Simulate the user clicking "proceed", there should be no crash. |
368 SendCommand("\"proceed\""); | 369 SendCommand("\"proceed\""); |
369 } | 370 } |
370 | 371 |
371 protected: | 372 protected: |
372 TestMalwareDetailsFactory details_factory_; | 373 TestMalwareDetailsFactory details_factory_; |
373 | 374 |
374 private: | 375 private: |
375 TestSafeBrowsingServiceFactory factory_; | 376 TestSafeBrowsingServiceFactory factory_; |
376 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; | 377 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; |
(...skipping 25 matching lines...) Expand all Loading... |
402 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { | 403 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { |
403 GURL url = test_server()->GetURL(kEmptyPage); | 404 GURL url = test_server()->GetURL(kEmptyPage); |
404 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 405 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
405 | 406 |
406 ui_test_utils::NavigateToURL(browser(), url); | 407 ui_test_utils::NavigateToURL(browser(), url); |
407 | 408 |
408 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 409 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
409 AssertNoInterstitial(false); // Assert the interstitial is gone | 410 AssertNoInterstitial(false); // Assert the interstitial is gone |
410 EXPECT_EQ( | 411 EXPECT_EQ( |
411 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 412 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
412 browser()->GetActiveWebContents()->GetURL()); | 413 chrome::GetActiveWebContents(browser())->GetURL()); |
413 } | 414 } |
414 | 415 |
415 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 416 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { |
416 GURL url = test_server()->GetURL(kEmptyPage); | 417 GURL url = test_server()->GetURL(kEmptyPage); |
417 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 418 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
418 | 419 |
419 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 420 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
420 // event that clears the interstitial. We wait for DidNavigate instead. | 421 // event that clears the interstitial. We wait for DidNavigate instead. |
421 ui_test_utils::NavigateToURL(browser(), url); | 422 ui_test_utils::NavigateToURL(browser(), url); |
422 ui_test_utils::WindowedNotificationObserver observer( | 423 ui_test_utils::WindowedNotificationObserver observer( |
423 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 424 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
424 content::Source<NavigationController>( | 425 content::Source<NavigationController>( |
425 &browser()->GetActiveWebContents()->GetController())); | 426 &chrome::GetActiveWebContents(browser())->GetController())); |
426 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 427 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
427 observer.Wait(); | 428 observer.Wait(); |
428 AssertNoInterstitial(true); // Assert the interstitial is gone. | 429 AssertNoInterstitial(true); // Assert the interstitial is gone. |
429 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL()); | 430 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
430 } | 431 } |
431 | 432 |
432 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { | 433 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { |
433 GURL url = test_server()->GetURL(kEmptyPage); | 434 GURL url = test_server()->GetURL(kEmptyPage); |
434 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 435 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
435 | 436 |
436 ui_test_utils::NavigateToURL(browser(), url); | 437 ui_test_utils::NavigateToURL(browser(), url); |
437 | 438 |
438 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" | 439 SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" |
439 AssertNoInterstitial(false); // Assert the interstitial is gone | 440 AssertNoInterstitial(false); // Assert the interstitial is gone |
440 EXPECT_EQ( | 441 EXPECT_EQ( |
441 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". | 442 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". |
442 browser()->GetActiveWebContents()->GetURL()); | 443 chrome::GetActiveWebContents(browser())->GetURL()); |
443 } | 444 } |
444 | 445 |
445 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { | 446 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { |
446 GURL url = test_server()->GetURL(kEmptyPage); | 447 GURL url = test_server()->GetURL(kEmptyPage); |
447 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 448 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
448 | 449 |
449 ui_test_utils::NavigateToURL(browser(), url); | 450 ui_test_utils::NavigateToURL(browser(), url); |
450 | 451 |
451 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 452 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
452 // event that clears the interstitial. We wait for DidNavigate instead. | 453 // event that clears the interstitial. We wait for DidNavigate instead. |
453 ui_test_utils::WindowedNotificationObserver observer( | 454 ui_test_utils::WindowedNotificationObserver observer( |
454 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 455 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
455 content::Source<NavigationController>( | 456 content::Source<NavigationController>( |
456 &browser()->GetActiveWebContents()->GetController())); | 457 &chrome::GetActiveWebContents(browser())->GetController())); |
457 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". | 458 SendCommand("\"proceed\""); // Simulate the user clicking "proceed". |
458 observer.Wait(); | 459 observer.Wait(); |
459 AssertNoInterstitial(true); // Assert the interstitial is gone | 460 AssertNoInterstitial(true); // Assert the interstitial is gone |
460 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL()); | 461 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
461 } | 462 } |
462 | 463 |
463 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { | 464 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { |
464 GURL url = test_server()->GetURL(kEmptyPage); | 465 GURL url = test_server()->GetURL(kEmptyPage); |
465 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 466 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
466 | 467 |
467 ui_test_utils::NavigateToURL(browser(), url); | 468 ui_test_utils::NavigateToURL(browser(), url); |
468 | 469 |
469 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 470 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
470 // event that clears the interstitial. We wait for DidNavigate instead. | 471 // event that clears the interstitial. We wait for DidNavigate instead. |
471 ui_test_utils::WindowedNotificationObserver observer( | 472 ui_test_utils::WindowedNotificationObserver observer( |
472 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 473 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
473 content::Source<NavigationController>( | 474 content::Source<NavigationController>( |
474 &browser()->GetActiveWebContents()->GetController())); | 475 &chrome::GetActiveWebContents(browser())->GetController())); |
475 SendCommand("\"reportError\""); // Simulate the user clicking "report error" | 476 SendCommand("\"reportError\""); // Simulate the user clicking "report error" |
476 observer.Wait(); | 477 observer.Wait(); |
477 AssertNoInterstitial(false); // Assert the interstitial is gone | 478 AssertNoInterstitial(false); // Assert the interstitial is gone |
478 | 479 |
479 // We are in the error reporting page. | 480 // We are in the error reporting page. |
480 EXPECT_EQ( | 481 EXPECT_EQ( |
481 "/safebrowsing/report_error/", | 482 "/safebrowsing/report_error/", |
482 browser()->GetActiveWebContents()->GetURL().path()); | 483 chrome::GetActiveWebContents(browser())->GetURL().path()); |
483 } | 484 } |
484 | 485 |
485 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 486 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
486 PhishingLearnMore) { | 487 PhishingLearnMore) { |
487 GURL url = test_server()->GetURL(kEmptyPage); | 488 GURL url = test_server()->GetURL(kEmptyPage); |
488 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | 489 AddURLResult(url, SafeBrowsingService::URL_PHISHING); |
489 | 490 |
490 ui_test_utils::NavigateToURL(browser(), url); | 491 ui_test_utils::NavigateToURL(browser(), url); |
491 | 492 |
492 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate | 493 // Note: NOTIFICATION_LOAD_STOP may come before or after the DidNavigate |
493 // event that clears the interstitial. We wait for DidNavigate instead. | 494 // event that clears the interstitial. We wait for DidNavigate instead. |
494 ui_test_utils::WindowedNotificationObserver observer( | 495 ui_test_utils::WindowedNotificationObserver observer( |
495 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 496 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
496 content::Source<NavigationController>( | 497 content::Source<NavigationController>( |
497 &browser()->GetActiveWebContents()->GetController())); | 498 &chrome::GetActiveWebContents(browser())->GetController())); |
498 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" | 499 SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" |
499 observer.Wait(); | 500 observer.Wait(); |
500 AssertNoInterstitial(false); // Assert the interstitial is gone | 501 AssertNoInterstitial(false); // Assert the interstitial is gone |
501 | 502 |
502 // We are in the help page. | 503 // We are in the help page. |
503 EXPECT_EQ( | 504 EXPECT_EQ( |
504 "/support/bin/answer.py", | 505 "/support/bin/answer.py", |
505 browser()->GetActiveWebContents()->GetURL().path()); | 506 chrome::GetActiveWebContents(browser())->GetURL().path()); |
506 } | 507 } |
507 | 508 |
508 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { | 509 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { |
509 GURL url = test_server()->GetURL(kMalwarePage); | 510 GURL url = test_server()->GetURL(kMalwarePage); |
510 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 511 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
511 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 512 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
512 | 513 |
513 ui_test_utils::NavigateToURL(browser(), url); | 514 ui_test_utils::NavigateToURL(browser(), url); |
514 | 515 |
515 ui_test_utils::WindowedNotificationObserver observer( | 516 ui_test_utils::WindowedNotificationObserver observer( |
516 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 517 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
517 content::Source<NavigationController>( | 518 content::Source<NavigationController>( |
518 &browser()->GetActiveWebContents()->GetController())); | 519 &chrome::GetActiveWebContents(browser())->GetController())); |
519 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" | 520 SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" |
520 observer.Wait(); | 521 observer.Wait(); |
521 AssertNoInterstitial(false); // Assert the interstitial is gone | 522 AssertNoInterstitial(false); // Assert the interstitial is gone |
522 | 523 |
523 EXPECT_EQ( | 524 EXPECT_EQ( |
524 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 525 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
525 browser()->GetActiveWebContents()->GetURL()); | 526 chrome::GetActiveWebContents(browser())->GetURL()); |
526 } | 527 } |
527 | 528 |
528 // Crashy, http://crbug.com/68834. | 529 // Crashy, http://crbug.com/68834. |
529 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 530 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
530 DISABLED_MalwareIframeProceed) { | 531 DISABLED_MalwareIframeProceed) { |
531 GURL url = test_server()->GetURL(kMalwarePage); | 532 GURL url = test_server()->GetURL(kMalwarePage); |
532 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 533 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
533 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 534 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
534 | 535 |
535 ui_test_utils::NavigateToURL(browser(), url); | 536 ui_test_utils::NavigateToURL(browser(), url); |
536 | 537 |
537 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" | 538 SendCommand("\"proceed\""); // Simulate the user clicking "proceed" |
538 AssertNoInterstitial(true); // Assert the interstitial is gone | 539 AssertNoInterstitial(true); // Assert the interstitial is gone |
539 | 540 |
540 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL()); | 541 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
541 } | 542 } |
542 | 543 |
543 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 544 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
544 MalwareIframeReportDetails) { | 545 MalwareIframeReportDetails) { |
545 GURL url = test_server()->GetURL(kMalwarePage); | 546 GURL url = test_server()->GetURL(kMalwarePage); |
546 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 547 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
547 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 548 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
548 | 549 |
549 ui_test_utils::NavigateToURL(browser(), url); | 550 ui_test_utils::NavigateToURL(browser(), url); |
550 | 551 |
551 // If the DOM details from renderer did not already return, wait for them. | 552 // If the DOM details from renderer did not already return, wait for them. |
552 details_factory_.get_details()->WaitForDOM(); | 553 details_factory_.get_details()->WaitForDOM(); |
553 | 554 |
554 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. | 555 SendCommand("\"doReport\""); // Simulate the user checking the checkbox. |
555 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 556 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
556 prefs::kSafeBrowsingReportingEnabled)); | 557 prefs::kSafeBrowsingReportingEnabled)); |
557 | 558 |
558 SendCommand("\"proceed\""); // Simulate the user clicking "back" | 559 SendCommand("\"proceed\""); // Simulate the user clicking "back" |
559 AssertNoInterstitial(true); // Assert the interstitial is gone | 560 AssertNoInterstitial(true); // Assert the interstitial is gone |
560 | 561 |
561 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL()); | 562 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); |
562 AssertReportSent(); | 563 AssertReportSent(); |
563 } | 564 } |
OLD | NEW |