Skip to content
Permalink
Browse files
Improve error message when clicking invalid link
  • Loading branch information
The-Compiler committed Jun 9, 2016
1 parent 8663280 commit 089131c79dbc069c5c5ce30f70b4392d1bd7d80a
Showing with 20 additions and 4 deletions.
  1. +3 −4 qutebrowser/browser/webpage.py
  2. +11 −0 tests/end2end/data/invalid_link.html
  3. +6 −0 tests/end2end/features/hints.feature
@@ -33,7 +33,7 @@
from qutebrowser.browser import http, tabhistory, pdfjs
from qutebrowser.browser.network import networkmanager
from qutebrowser.utils import (message, usertypes, log, jinja, qtutils, utils,
objreg, debug)
objreg, debug, urlutils)


class BrowserPage(QWebPage):
@@ -570,9 +570,8 @@ def acceptNavigationRequest(self, _frame, request, typ):
if typ != QWebPage.NavigationTypeLinkClicked:
return True
if not url.isValid():
message.error(self._win_id, "Invalid link {} clicked!".format(
urlstr))
log.webview.debug(url.errorString())
msg = urlutils.get_errstring(url, "Invalid link clicked")
message.error(self._win_id, msg)
self.open_target = usertypes.ClickTarget.normal
return False
tabbed_browser = objreg.get('tabbed-browser', scope='window',
@@ -0,0 +1,11 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<title>Invalid link</title>
</head>
<body>
<a href="what://::">I'm broken</a>
</body>
</html>
@@ -113,6 +113,12 @@ Feature: Using hints
And I run :follow-hint a
Then the message "http://localhost:(port)/data/hello.txt" should be shown

Scenario: Clicking an invalid link
When I open data/invalid_link.html
And I run :hint all
And I run :follow-hint a
Then the error "Invalid link clicked - *" should be shown

### iframes

Scenario: Using :follow-hint inside an iframe

0 comments on commit 089131c

Please sign in to comment.