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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 2837233002: Reland of SafeBrowsing: update interstitial layouts (Closed)
Patch Set: Fix formatting Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/security_interstitials/core/browser/resources/interstitial_v2.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
index a8c8bffc85b18c6e34acd9615cd9320f2d712969..c8c7fada128e363657e48157f2c542500b3272df 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -562,13 +562,26 @@ class SafeBrowsingBlockingPageBrowserTest
if (!rfh)
return VISIBILITY_ERROR;
- std::unique_ptr<base::Value> value = content::ExecuteScriptAndGetValue(
- rfh, "var node = document.getElementById('" + node_id +
- "');\n"
- "if (node)\n"
- " node.offsetWidth > 0 && node.offsetHeight > 0;"
- "else\n"
- " 'node not found';\n");
+ // clang-format off
+ std::string jsFindVisibility = R"(
+ (function isNodeVisible(node) {
+ if (!node) return 'node not found';
+ if (node.offsetWidth === 0 || node.offsetHeight === 0) return false;
+ // Don't check opacity, since the css transition may actually leave
+ // opacity at 0 after it's been unhidden
+ if (node.classList.contains('hidden')) return false;
+ // Otherwise, we must check all parent nodes
+ var parentVisibility = isNodeVisible(node.parentElement);
+ if (parentVisibility === 'node not found') {
+ return true; // none of the parents are set invisible
+ }
+ return parentVisibility;
+ }(document.getElementById(')" + node_id + R"(')));)";
+ // clang-format on
+
+ std::unique_ptr<base::Value> value =
+ content::ExecuteScriptAndGetValue(rfh, jsFindVisibility);
+
if (!value.get())
return VISIBILITY_ERROR;
« no previous file with comments | « no previous file | components/security_interstitials/core/browser/resources/interstitial_v2.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698