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..aacb7b2227be308abe1784ac4c0b81c864a03ac1 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,25 @@ 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"); |
+ 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"(')));)"; |
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.
|
+ |
+ std::unique_ptr<base::Value> value = |
+ content::ExecuteScriptAndGetValue(rfh, jsFindVisibility); |
+ |
if (!value.get()) |
return VISIBILITY_ERROR; |