Skip to content
Permalink
Browse files

QtWebEngine: Don't add invalid URLs to history

  • Loading branch information
The-Compiler committed Sep 5, 2016
1 parent 8115fa2 commit f2c4cedf619f89045172ce2be57ea1c8416ecead
@@ -504,6 +504,11 @@ def _on_history_trigger(self):
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):
@@ -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>

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

0 comments on commit f2c4ced

Please sign in to comment.