diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index 3c9a4b949..8ad837ee9 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -184,8 +184,6 @@ class WebElementWrapper(collections.abc.MutableMapping): def is_content_editable(self): """Check if an element has a contenteditable attribute. - FIXME: Add tests. - Args: elem: The QWebElement to check. @@ -250,8 +248,6 @@ class WebElementWrapper(collections.abc.MutableMapping): def is_editable(self, strict=False): """Check whether we should switch to insert mode for this element. - FIXME: add tests - Args: strict: Whether to do stricter checking so only fields where we can get the value match, for use with the :editor command. diff --git a/tests/browser/test_webelem.py b/tests/browser/test_webelem.py index aca064a61..5051aadfd 100644 --- a/tests/browser/test_webelem.py +++ b/tests/browser/test_webelem.py @@ -24,7 +24,10 @@ from unittest import mock import collections.abc import operator +import itertools +import hypothesis +import hypothesis.strategies from PyQt5.QtCore import QRect, QPoint from PyQt5.QtWebKit import QWebElement import pytest @@ -89,9 +92,105 @@ def get_webelem(geometry=None, frame=None, null=False, style=None, return wrapped +class SelectionAndFilterTests: + + """Generator for tests for TestSelectionsAndFilters.""" + + # A mapping of a HTML element to a list of groups where the selectors + # (after filtering) should match. + # + # Based on this, test cases are generated to make sure it matches those + # groups and not the others. + + TESTS = [ + ('', []), + ('', []), + ('', [webelem.Group.url]), + ('', [webelem.Group.url]), + + ('', [webelem.Group.all]), + ('', [webelem.Group.all, webelem.Group.links, + webelem.Group.prevnext, webelem.Group.url]), + ('', [webelem.Group.all, + webelem.Group.url]), + + ('', [webelem.Group.all]), + ('', [webelem.Group.all, webelem.Group.links, + webelem.Group.prevnext, webelem.Group.url]), + ('', [webelem.Group.all, + webelem.Group.url]), + + ('', [webelem.Group.all]), + ('', [webelem.Group.all, webelem.Group.links, + webelem.Group.prevnext, webelem.Group.url]), + ('', [webelem.Group.all, + webelem.Group.url]), + + ('