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

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

Issue 2837233002: Reland of SafeBrowsing: update interstitial layouts (Closed)
Patch Set: Fix nits Created 3 years, 7 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 <algorithm> 9 #include <algorithm>
10 10
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 if (!interstitial) 555 if (!interstitial)
556 return false; 556 return false;
557 return content::WaitForRenderFrameReady(interstitial->GetMainFrame()); 557 return content::WaitForRenderFrameReady(interstitial->GetMainFrame());
558 } 558 }
559 559
560 Visibility GetVisibility(const std::string& node_id) { 560 Visibility GetVisibility(const std::string& node_id) {
561 content::RenderFrameHost* rfh = GetRenderFrameHost(); 561 content::RenderFrameHost* rfh = GetRenderFrameHost();
562 if (!rfh) 562 if (!rfh)
563 return VISIBILITY_ERROR; 563 return VISIBILITY_ERROR;
564 564
565 std::unique_ptr<base::Value> value = content::ExecuteScriptAndGetValue( 565 std::string jsFindVisibility = R"(
566 rfh, "var node = document.getElementById('" + node_id + 566 (function isNodeVisible(node) {
567 "');\n" 567 if (!node) return 'node not found';
568 "if (node)\n" 568 if (node.offsetWidth === 0 || node.offsetHeight === 0) return false;
569 " node.offsetWidth > 0 && node.offsetHeight > 0;" 569 // Don't check opacity, since the css transition may actually leave
570 "else\n" 570 // opacity at 0 after it's been unhidden
571 " 'node not found';\n"); 571 if (node.classList.contains('hidden')) return false;
572 // Otherwise, we must check all parent nodes
573 var parentVisibility = isNodeVisible(node.parentElement);
574 if (parentVisibility === 'node not found') {
575 return true; // none of the parents are set invisible
576 }
577 return parentVisibility;
578 }(document.getElementById(')" +
579 node_id + R"(')));)";
Jialiu Lin 2017/04/27 20:44:40 nit: strange indentation.
Nate Fischer 2017/04/27 20:47:54 I agree, that's what clang-format did. Is it accep
Jialiu Lin 2017/04/27 20:51:37 Sure.
580
581 std::unique_ptr<base::Value> value =
582 content::ExecuteScriptAndGetValue(rfh, jsFindVisibility);
583
572 if (!value.get()) 584 if (!value.get())
573 return VISIBILITY_ERROR; 585 return VISIBILITY_ERROR;
574 586
575 bool result = false; 587 bool result = false;
576 if (!value->GetAsBoolean(&result)) 588 if (!value->GetAsBoolean(&result))
577 return VISIBILITY_ERROR; 589 return VISIBILITY_ERROR;
578 590
579 return result ? VISIBLE : HIDDEN; 591 return result ? VISIBLE : HIDDEN;
580 } 592 }
581 593
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 1485
1474 INSTANTIATE_TEST_CASE_P( 1486 INSTANTIATE_TEST_CASE_P(
1475 SafeBrowsingBlockingPageIDNTestWithThreatType, 1487 SafeBrowsingBlockingPageIDNTestWithThreatType,
1476 SafeBrowsingBlockingPageIDNTest, 1488 SafeBrowsingBlockingPageIDNTest,
1477 testing::Combine(testing::Values(false, true), 1489 testing::Combine(testing::Values(false, true),
1478 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 1490 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
1479 SB_THREAT_TYPE_URL_PHISHING, 1491 SB_THREAT_TYPE_URL_PHISHING,
1480 SB_THREAT_TYPE_URL_UNWANTED))); 1492 SB_THREAT_TYPE_URL_UNWANTED)));
1481 1493
1482 } // namespace safe_browsing 1494 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698