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

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

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (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 known- 5 // This test creates a fake safebrowsing service, where we can inject known-
6 // threat urls. It then uses a real browser to go to these urls, and sends 6 // threat urls. It then uses a real browser to go to these urls, and sends
7 // "goback" or "proceed" commands and verifies they work. 7 // "goback" or "proceed" commands and verifies they work.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return result ? VISIBLE : HIDDEN; 561 return result ? VISIBLE : HIDDEN;
562 } 562 }
563 563
564 bool Click(const std::string& node_id) { 564 bool Click(const std::string& node_id) {
565 content::RenderViewHost* rvh = GetRenderViewHost(); 565 content::RenderViewHost* rvh = GetRenderViewHost();
566 if (!rvh) 566 if (!rvh)
567 return false; 567 return false;
568 // We don't use ExecuteScriptAndGetValue for this one, since clicking 568 // We don't use ExecuteScriptAndGetValue for this one, since clicking
569 // the button/link may navigate away before the injected javascript can 569 // the button/link may navigate away before the injected javascript can
570 // reply, hanging the test. 570 // reply, hanging the test.
571 rvh->GetMainFrame()->ExecuteJavaScript( 571 rvh->GetMainFrame()->ExecuteJavaScriptForTests(
572 base::ASCIIToUTF16( 572 base::ASCIIToUTF16(
573 "document.getElementById('" + node_id + "').click();\n")); 573 "document.getElementById('" + node_id + "').click();\n"));
574 return true; 574 return true;
575 } 575 }
576 576
577 bool ClickAndWaitForDetach(const std::string& node_id) { 577 bool ClickAndWaitForDetach(const std::string& node_id) {
578 // We wait for interstitial_detached rather than nav_entry_committed, as 578 // We wait for interstitial_detached rather than nav_entry_committed, as
579 // going back from a main-frame malware interstitial page will not cause a 579 // going back from a main-frame malware interstitial page will not cause a
580 // nav entry committed event. 580 // nav entry committed event.
581 if (!Click(node_id)) 581 if (!Click(node_id))
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, 866 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest,
867 SafeBrowsingBlockingPageDecodesIDN) { 867 SafeBrowsingBlockingPageDecodesIDN) {
868 EXPECT_TRUE(VerifyIDNDecoded()); 868 EXPECT_TRUE(VerifyIDNDecoded());
869 } 869 }
870 870
871 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, 871 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType,
872 SafeBrowsingBlockingPageIDNTest, 872 SafeBrowsingBlockingPageIDNTest,
873 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 873 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
874 SB_THREAT_TYPE_URL_PHISHING, 874 SB_THREAT_TYPE_URL_PHISHING,
875 SB_THREAT_TYPE_URL_UNWANTED)); 875 SB_THREAT_TYPE_URL_UNWANTED));
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | chrome/browser/task_manager/task_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698