diff options
author | Florian Bruhin <git@the-compiler.org> | 2017-02-24 09:12:59 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2017-02-24 09:13:25 +0100 |
commit | 3feb4211fe809e31b74613ffd541ad20d63b3714 (patch) | |
tree | f491aedfd3dd63e8dbeb57241cc60b07e05bca82 | |
parent | e832105dd5aa876e0edefa489976674bcad9cbf2 (diff) | |
download | qutebrowser-3feb4211fe809e31b74613ffd541ad20d63b3714.tar.gz qutebrowser-3feb4211fe809e31b74613ffd541ad20d63b3714.zip |
Don't show hints for opacity: 0 elements
Fixes #2347
-rw-r--r-- | qutebrowser/browser/webkit/webkitelem.py | 1 | ||||
-rw-r--r-- | qutebrowser/javascript/webelem.js | 3 | ||||
-rw-r--r-- | tests/end2end/data/hints/invisible.html | 14 | ||||
-rw-r--r-- | tests/end2end/features/hints.feature | 5 |
4 files changed, 22 insertions, 1 deletions
diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index d94e6996a..a27d0f5fe 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -248,6 +248,7 @@ class WebKitElement(webelem.AbstractWebElement): hidden_attributes = { 'visibility': 'hidden', 'display': 'none', + 'opacity': '0', } for k, v in hidden_attributes.items(): if self._elem.styleProperty(k, QWebElement.ComputedStyle) == v: diff --git a/qutebrowser/javascript/webelem.js b/qutebrowser/javascript/webelem.js index 377a7575c..aef2fa3c8 100644 --- a/qutebrowser/javascript/webelem.js +++ b/qutebrowser/javascript/webelem.js @@ -115,7 +115,8 @@ window._qutebrowser.webelem = (function() { // See https://github.com/vimperator/vimperator-labs/issues/236 if (elem.nodeName.toLowerCase() !== "area" && ( style.getPropertyValue("visibility") !== "visible" || - style.getPropertyValue("display") === "none")) { + style.getPropertyValue("display") === "none" || + style.getPropertyValue("opacity") === "0")) { return false; } diff --git a/tests/end2end/data/hints/invisible.html b/tests/end2end/data/hints/invisible.html new file mode 100644 index 000000000..b0bfa9dd9 --- /dev/null +++ b/tests/end2end/data/hints/invisible.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> + +<html> + <head> + <meta charset="utf-8"> + <title>Invisible links</title> + </head> + <body> + <p>None of those invisible links should get a hint.</p> + <a href="/data/hello.txt" style="visibility: hidden">visibility: hidden</a> + <a href="/data/hello.txt" style="display: none">display: none</a> + <a href="/data/hello.txt" style="opacity: 0">opacity: 0</a> + </body> +</html> diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index 772ffec55..68dc9bb1e 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -183,6 +183,11 @@ Feature: Using hints # The actual check is already done above Then no crash should happen + Scenario: Hinting invisible elements + When I open data/hints/invisible.html + And I run :hint + Then the error "No elements found." should be shown + ### iframes @qtwebengine_todo: Hinting in iframes is not implemented yet |