From 200c11625f4dd6fb2a36f3dcb674402918da6c79 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 14 Sep 2018 21:58:42 +0200 Subject: [PATCH] Revert "Make sure we wait until follow_selected is done" This reverts commit bc45aa33e0ac58e8ccd54508b36dc0b463c4c3c3. --- qutebrowser/browser/browsertab.py | 2 -- qutebrowser/browser/webengine/webenginetab.py | 6 +----- qutebrowser/browser/webkit/webkittab.py | 5 ----- tests/unit/browser/test_caret.py | 14 ++++++-------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 0eb9b6493..087834e53 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -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) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 78913e92e..3eec5669c 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -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 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: diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 041e058b1..7b7ad0c7d 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -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( '{}'.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): diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py index 70677361c..5e1be7e74 100644 --- a/tests/unit/browser/test_caret.py +++ b/tests/unit/browser/test_caret.py @@ -336,19 +336,17 @@ 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) + with qtbot.assert_not_emitted(web_tab.load_started): + caret.follow_selected() + qtbot.wait(self.LOAD_STARTED_DELAY) def test_follow_selected_with_text(self, qtbot, caret, selection, web_tab): 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) + with qtbot.assert_not_emitted(web_tab.load_started): + caret.follow_selected() + qtbot.wait(self.LOAD_STARTED_DELAY) @pytest.mark.parametrize('with_js', [True, False]) def test_follow_selected_with_link(self, caret, selection, config_stub,