diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index d29ee8ed3..97f810e67 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -504,6 +504,11 @@ class WebEngineTab(browsertab.AbstractTab): if title == title_url.toDisplayString(QUrl.RemoveScheme).strip('/'): title = "" + # Don't add history entry if the URL is invalid anyways + if not url.isValid(): + log.misc.debug("Ignoring invalid URL being added to history") + return + self.add_history_item.emit(url, requested_url, title) def _connect_signals(self): diff --git a/tests/end2end/data/javascript/window_open.html b/tests/end2end/data/javascript/window_open.html index af09755e0..b8e178db3 100644 --- a/tests/end2end/data/javascript/window_open.html +++ b/tests/end2end/data/javascript/window_open.html @@ -17,6 +17,10 @@ my_window = window.open('about:blank', 'my_window'); } + function open_invalid() { + window.open('', 'my_window'); + } + function close() { my_window.close(); } @@ -32,6 +36,7 @@ + diff --git a/tests/end2end/features/backforward.feature b/tests/end2end/features/backforward.feature index 1b43cac4d..835ad9351 100644 --- a/tests/end2end/features/backforward.feature +++ b/tests/end2end/features/backforward.feature @@ -88,7 +88,6 @@ Feature: Going back and forward. - url: http://localhost:*/data/backforward/2.txt - url: http://localhost:*/data/backforward/3.txt - @qtwebengine_skip: Causes 'Ignoring invalid URL being added to history' sometimes? Scenario: Going back too much with count. Given I open data/backforward/1.txt When I open data/backforward/2.txt @@ -138,7 +137,6 @@ Feature: Going back and forward. When I run :forward Then the error "At end of history." should be shown - @qtwebengine_skip: Causes 'Ignoring invalid URL being added to history' sometimes? Scenario: Going forward too much with count. Given I open data/backforward/1.txt When I open data/backforward/2.txt diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index badb26aac..f6ea4c79f 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -48,6 +48,11 @@ Feature: Page history Then the history file should contain: http://localhost:(port)/status/404 Error loading page: http://localhost:(port)/status/404 + Scenario: History with invalid URL + When I open data/javascript/window_open.html + And I run :click-element id open-invalid + Then "Changing title for idx 1 to 'about:blank'" should be logged + Scenario: Clearing history When I open data/title.html And I run :history-clear