QtWebEngine: Don't add invalid URLs to history

This commit is contained in:
Florian Bruhin 2016-09-05 14:56:02 +02:00
parent 8115fa2af8
commit f2c4cedf61
4 changed files with 15 additions and 2 deletions

View File

@ -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):

View File

@ -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 @@
<button onclick="open_normal()" id="open-normal">normal</button>
<button onclick="open_modal()" id="open-modal">modal</button>
<button onclick="open_invalid()" id="open-invalid">invalid/no URL</button>
<button onclick="close()" id="close-normal">close</button>
<button onclick="close_twice()" id="close-twice">close twice (issue 906)</button>

View File

@ -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

View File

@ -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