Revert "Make sure we wait until follow_selected is done"

This reverts commit bc45aa33e0.
This commit is contained in:
Florian Bruhin 2018-09-14 21:58:42 +02:00
parent 8d066690e6
commit 200c11625f
4 changed files with 7 additions and 20 deletions

View File

@ -395,11 +395,9 @@ class AbstractCaret(QObject):
Signals:
selection_toggled: Emitted when the selection was toggled.
arg: Whether the selection is now active.
follow_selected_done: Emitted when a follow_selection action is done.
"""
selection_toggled = pyqtSignal(bool)
follow_selected_done = pyqtSignal()
def __init__(self, tab, mode_manager, parent=None):
super().__init__(parent)

View File

@ -344,13 +344,10 @@ class WebEngineCaret(browsertab.AbstractCaret):
tab: Open in a new tab.
"""
if js_elem is None:
self.follow_selected_done.emit()
return
if js_elem == "focused":
# we had a focused element, not a selected one. Just send <enter>
self._follow_enter(tab)
self.follow_selected_done.emit()
return
assert isinstance(js_elem, dict), js_elem
@ -368,8 +365,7 @@ class WebEngineCaret(browsertab.AbstractCaret):
elem.click(click_type)
except webelem.Error as e:
message.error(str(e))
self.follow_selected_done.emit()
return
def follow_selected(self, *, tab=False):
if self._tab.search.search_displayed:

View File

@ -369,13 +369,11 @@ class WebKitCaret(browsertab.AbstractCaret):
# https://github.com/annulen/webkit/commit/0e75f3272d149bc64899c161f150eb341a2417af
# TODO find a way to check if something is focused
self._follow_enter(tab)
self.follow_selected_done.emit()
return
try:
selected_element = xml.etree.ElementTree.fromstring(
'<html>{}</html>'.format(selection)).find('a')
except xml.etree.ElementTree.ParseError:
self.follow_selected_done.emit()
raise browsertab.WebTabError('Could not parse selected '
'element!')
@ -383,7 +381,6 @@ class WebKitCaret(browsertab.AbstractCaret):
try:
url = selected_element.attrib['href']
except KeyError:
self.follow_selected_done.emit()
raise browsertab.WebTabError('Anchor element without '
'href!')
url = self._tab.url().resolved(QUrl(url))
@ -392,8 +389,6 @@ class WebKitCaret(browsertab.AbstractCaret):
else:
self._tab.openurl(url)
self.follow_selected_done.emit()
class WebKitZoom(browsertab.AbstractZoom):

View File

@ -336,7 +336,6 @@ class TestFollowSelected:
def test_follow_selected_without_a_selection(self, qtbot, caret, selection, web_tab,
mode_manager):
mode_manager.leave(usertypes.KeyMode.caret)
with qtbot.wait_signal(caret.follow_selected_done):
with qtbot.assert_not_emitted(web_tab.load_started):
caret.follow_selected()
qtbot.wait(self.LOAD_STARTED_DELAY)
@ -345,7 +344,6 @@ class TestFollowSelected:
caret.move_to_next_word()
selection.toggle()
caret.move_to_end_of_word()
with qtbot.wait_signal(caret.follow_selected_done):
with qtbot.assert_not_emitted(web_tab.load_started):
caret.follow_selected()
qtbot.wait(self.LOAD_STARTED_DELAY)