diff --git a/qutebrowser/javascript/webelem.js b/qutebrowser/javascript/webelem.js index 3b0e324dd..f9bd7d1af 100644 --- a/qutebrowser/javascript/webelem.js +++ b/qutebrowser/javascript/webelem.js @@ -50,7 +50,6 @@ window._qutebrowser.webelem = (function() { var out = { "id": id, - "text": elem.text, "value": elem.value, "outer_xml": elem.outerHTML, "rects": [], // Gets filled up later @@ -72,6 +71,12 @@ window._qutebrowser.webelem = (function() { out.class_name = ""; } + if (typeof elem.textContent === "string") { + out.text = elem.textContent; + } else if (typeof elem.text === "string") { + out.text = elem.text; + } // else: don't add the text at all + var attributes = {}; for (var i = 0; i < elem.attributes.length; ++i) { var attr = elem.attributes[i]; diff --git a/tests/end2end/data/issue2569.html b/tests/end2end/data/issue2569.html index 4bff70e14..8f613be2d 100644 --- a/tests/end2end/data/issue2569.html +++ b/tests/end2end/data/issue2569.html @@ -1,11 +1,21 @@ + Form with tagName child -
+ +
+ +
+ +
+ diff --git a/tests/end2end/features/javascript.feature b/tests/end2end/features/javascript.feature index c0c5344d2..7ea712d15 100644 --- a/tests/end2end/features/javascript.feature +++ b/tests/end2end/features/javascript.feature @@ -79,7 +79,13 @@ Feature: Javascript stuff # https://github.com/qutebrowser/qutebrowser/issues/2569 Scenario: Clicking on form element with tagName child When I open data/issue2569.html - And I run :click-element id theform + And I run :click-element id tagnameform + And I wait for "Sending fake click to *" in the log + Then no crash should happen + + Scenario: Clicking on form element with text child + When I open data/issue2569.html + And I run :click-element id textform And I wait for "Sending fake click to *" in the log Then no crash should happen