Permalink
Browse files

Get rid of webelem.run_js_async

  • Loading branch information...
The-Compiler committed Sep 7, 2016
1 parent 78d64f4 commit 8f9cfcf2323c0c8dfa36fe716308a8fba0f96c48
@@ -162,11 +162,6 @@ def insert_text(self, text):
"""Insert the given text into the element."""
raise NotImplementedError
- def run_js_async(self, code, callback=None):
- """Run the given JS snippet async on the element."""
- # FIXME:qtwebengine get rid of this?
- raise NotImplementedError
-
def parent(self):
"""Get the parent element of this element."""
# FIXME:qtwebengine get rid of this?
@@ -115,11 +115,6 @@ def insert_text(self, text):
js_code = javascript.assemble('webelem', 'insert_text', self._id, text)
self._tab.run_js_async(js_code)
- def run_js_async(self, code, callback=None):
- """Run the given JS snippet async on the element."""
- # FIXME:qtwebengine get rid of this?
- log.stub()
-
def parent(self):
"""Get the parent element of this element."""
# FIXME:qtwebengine get rid of this?
@@ -139,20 +139,13 @@ def insert_text(self, text):
if not self.is_editable(strict=True):
raise webelem.Error("Element is not editable!")
log.misc.debug("Inserting text into element {!r}".format(self))
- self.run_js_async("""
+ self._elem.evaluateJavaScript("""
var text = '{}';
var event = document.createEvent('TextEvent');
event.initTextEvent('textInput', true, true, null, text);
this.dispatchEvent(event);
""".format(javascript.string_escape(text)))
- def run_js_async(self, code, callback=None):
- """Run the given JS snippet async on the element."""
- self._check_vanished()
- result = self._elem.evaluateJavaScript(code)
- if callback is not None:
- callback(result)
-
def parent(self):
self._check_vanished()
elem = self._elem.parent()
@@ -268,14 +268,13 @@ def test_double_wrap(self, elem):
lambda e: e.debug_text(),
lambda e: e.outer_xml(),
lambda e: e.tag_name(),
- lambda e: e.run_js_async(''),
lambda e: e.rect_on_view(),
lambda e: e.is_visible(None),
], ids=['str', 'getitem', 'setitem', 'delitem', 'contains', 'iter', 'len',
'frame', 'geometry', 'style_property', 'text', 'set_text',
'is_writable', 'is_content_editable', 'is_editable',
'is_text_input', 'remove_blank_target', 'debug_text', 'outer_xml',
- 'tag_name', 'run_js_async', 'rect_on_view', 'is_visible'])
+ '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
@@ -442,14 +441,6 @@ def test_set_text(self, use_js, editable, text, uses_js, arg):
called_mock = getattr(elem._elem, attr)
called_mock.assert_called_with(arg)
- @pytest.mark.parametrize('with_cb', [True, False])
- def test_run_js_async(self, elem, with_cb):
- cb = mock.Mock(spec={}) if with_cb else None
- elem._elem.evaluateJavaScript.return_value = 42
- elem.run_js_async('the_answer();', cb)
- if with_cb:
- cb.assert_called_with(42)
-
class TestRemoveBlankTarget:

0 comments on commit 8f9cfcf

Please sign in to comment.