fix test related to view-source
remove pygment title remove view-source from history
This commit is contained in:
parent
eb888cc8d7
commit
bb8bc7ea3c
@ -172,7 +172,7 @@ class WebHistory(sql.SqlTable):
|
||||
@pyqtSlot(QUrl, QUrl, str)
|
||||
def add_from_tab(self, url, requested_url, title):
|
||||
"""Add a new history entry as slot, called from a BrowserTab."""
|
||||
if any(url.scheme() == 'data' or
|
||||
if any(url.scheme() in ('data', 'view-source') or
|
||||
(url.scheme(), url.host()) == ('qute', 'back')
|
||||
for url in (url, requested_url)):
|
||||
return
|
||||
|
@ -104,11 +104,13 @@ class WebEngineAction(browsertab.AbstractAction):
|
||||
self._widget.triggerPageAction(QWebEnginePage.ViewSource)
|
||||
except AttributeError:
|
||||
# Qt < 5.8
|
||||
url_str = self._tab.url().toString(QUrl.RemoveUserInfo)
|
||||
new_url = QUrl('view-source:' + url_str)
|
||||
tb = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
tb.tabopen(new_url, background=False, related=True)
|
||||
url_str = self._tab.url().toString(QUrl.RemoveUserInfo)
|
||||
# The original URL becomes the path of a view-source: URL
|
||||
# (without a host), but query/fragment should stay.
|
||||
url = QUrl('view-source:' + url_str)
|
||||
tb.tabopen(url, background=False, related=True)
|
||||
|
||||
|
||||
class WebEnginePrinting(browsertab.AbstractPrinting):
|
||||
|
@ -62,16 +62,17 @@ class WebKitAction(browsertab.AbstractAction):
|
||||
# pylint: disable=no-member
|
||||
lexer = pygments.lexers.HtmlLexer()
|
||||
formatter = pygments.formatters.HtmlFormatter(
|
||||
full=True, linenos='table',
|
||||
title='Source for {}'.format(url_str))
|
||||
full=True, linenos='table')
|
||||
# pylint: enable=no-member
|
||||
highlighted = pygments.highlight(source, lexer, formatter)
|
||||
|
||||
base_url = QUrl('view-source:' + url_str)
|
||||
tb = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id)
|
||||
new_tab = tb.tabopen(background=False, related=True)
|
||||
new_tab.set_html(highlighted, base_url)
|
||||
# The original URL becomes the path of a view-source: URL
|
||||
# (without a host), but query/fragment should stay.
|
||||
url = QUrl('view-source:' + url_str)
|
||||
new_tab.set_html(highlighted, url)
|
||||
|
||||
url_str = self._tab.url().toString(QUrl.RemoveUserInfo)
|
||||
self._tab.dump_async(show_source_cb)
|
||||
|
@ -69,7 +69,7 @@ Feature: Page history
|
||||
Scenario: History with view-source URL
|
||||
When I open data/title.html
|
||||
And I run :view-source
|
||||
And I wait for regex "Changing title for idx \d+ to '(Source for |view-source:)(http://)?localhost:\d+/data/title.html'" in the log
|
||||
And I wait for regex "Changing title for idx \d+ to 'view-source:(http://)?localhost:\d+/data/title.html'" in the log
|
||||
Then the history should contain:
|
||||
http://localhost:(port)/data/title.html Test title
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user