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

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

Powered by Google App Engine
This is Rietveld 408576698