diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py
index c78714315..cf4619924 100644
--- a/qutebrowser/browser/navigate.py
+++ b/qutebrowser/browser/navigate.py
@@ -75,8 +75,7 @@ def _find_prevnext(prev, elems):
if e.tag_name() != 'link' or 'rel' not in e:
continue
if e['rel'] in rel_values:
- log.hints.debug("Found '{}' with rel={}".format(
- e.debug_text(), e['rel']))
+ log.hints.debug("Found {!r} with rel={}".format(e, e['rel']))
return e
# Then check for regular links/buttons.
diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py
index 320879ab6..6adc5e69f 100644
--- a/qutebrowser/browser/webelem.py
+++ b/qutebrowser/browser/webelem.py
@@ -106,7 +106,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
def __repr__(self):
try:
- html = self.debug_text()
+ html = utils.compact_text(self.outer_xml(), 500)
except Error:
html = None
return utils.get_repr(self, html=html)
@@ -310,10 +310,6 @@ class AbstractWebElement(collections.abc.MutableMapping):
break
elem = elem.parent()
- def debug_text(self):
- """Get a text based on an element suitable for debug output."""
- return utils.compact_text(self.outer_xml(), 500)
-
def resolve_url(self, baseurl):
"""Resolve the URL in the element's src/href attribute.
@@ -365,9 +361,8 @@ class AbstractWebElement(collections.abc.MutableMapping):
pos = self._mouse_pos()
- log.hints.debug("Sending fake click to '{}' at position {} with "
- "target {}".format(self.debug_text(), pos,
- click_target))
+ log.hints.debug("Sending fake click to {!r} at position {} with "
+ "target {}".format(self, pos, click_target))
if click_target in [usertypes.ClickTarget.tab,
usertypes.ClickTarget.tab_bg,
diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py
index f8e98a04e..868bd4284 100644
--- a/qutebrowser/browser/webkit/webkitelem.py
+++ b/qutebrowser/browser/webkit/webkitelem.py
@@ -126,12 +126,10 @@ class WebKitElement(webelem.AbstractWebElement):
def set_text(self, text, *, use_js=False):
self._check_vanished()
if self.is_content_editable() or not use_js:
- log.misc.debug("Filling element {} via set_text.".format(
- self.debug_text()))
+ log.misc.debug("Filling {!r} via set_text.".format(self))
self._elem.setPlainText(text)
else:
- log.misc.debug("Filling element {} via javascript.".format(
- self.debug_text()))
+ log.misc.debug("Filling {!r} via javascript.".format(self))
text = javascript.string_escape(text)
self._elem.evaluateJavaScript("this.value='{}'".format(text))
diff --git a/tests/unit/browser/webkit/test_webkitelem.py b/tests/unit/browser/webkit/test_webkitelem.py
index ca9a7dd07..78c1a2437 100644
--- a/tests/unit/browser/webkit/test_webkitelem.py
+++ b/tests/unit/browser/webkit/test_webkitelem.py
@@ -266,7 +266,6 @@ class TestWebKitElement:
lambda e: e.is_editable(),
lambda e: e.is_text_input(),
lambda e: e.remove_blank_target(),
- lambda e: e.debug_text(),
lambda e: e.outer_xml(),
lambda e: e.tag_name(),
lambda e: e.rect_on_view(),
@@ -274,8 +273,8 @@ class TestWebKitElement:
], ids=['str', 'getitem', 'setitem', 'delitem', 'contains', 'iter', 'len',
'frame', 'geometry', 'style_property', 'text', 'set_text',
'insert_text', 'is_writable', 'is_content_editable', 'is_editable',
- 'is_text_input', 'remove_blank_target', 'debug_text', 'outer_xml',
- 'tag_name', 'rect_on_view', 'is_visible'])
+ 'is_text_input', 'remove_blank_target', 'outer_xml', 'tag_name',
+ 'rect_on_view', 'is_visible'])
def test_vanished(self, elem, code):
"""Make sure methods check if the element is vanished."""
elem._elem.isNull.return_value = True
@@ -286,14 +285,19 @@ class TestWebKitElement:
def test_str(self, elem):
assert str(elem) == 'text'
- @pytest.mark.parametrize('is_null, expected', [
- (False, "'>"),
- (True, ''),
+ wke_qualname = 'qutebrowser.browser.webkit.webkitelem.WebKitElement'
+
+ @pytest.mark.parametrize('is_null, xml, expected', [
+ (False, '', "<{} html=''>".format(wke_qualname)),
+ (False, '\n\n',
+ "<{} html=''>".format(wke_qualname)),
+ (False, '{}'.format('x' * 500),
+ "<{} html='{}…'>".format(wke_qualname, 'x' * 494)),
+ (True, None, '<{} html=None>'.format(wke_qualname)),
])
- def test_repr(self, elem, is_null, expected):
+ def test_repr(self, elem, is_null, xml, expected):
elem._elem.isNull.return_value = is_null
+ elem._elem.toOuterXml.return_value = xml
assert repr(elem) == expected
def test_getitem(self):
@@ -384,15 +388,6 @@ class TestWebKitElement:
elem = get_webelem(tagname=tagname, attributes=attributes)
assert elem.is_text_input() == expected
- @pytest.mark.parametrize('xml, expected', [
- ('', ''),
- ('\n\n', ''),
- ('{}'.format('x' * 500), '{}…'.format('x' * 494)),
- ], ids=['fakeelem', 'newlines', 'long'])
- def test_debug_text(self, elem, xml, expected):
- elem._elem.toOuterXml.return_value = xml
- assert elem.debug_text() == expected
-
@pytest.mark.parametrize('attribute, code', [
('geometry', lambda e: e.geometry()),
('toOuterXml', lambda e: e.outer_xml()),