QtWebEngine: Initial session implementation
This commit is contained in:
parent
4f55b435f0
commit
1ed637a906
@ -24,7 +24,7 @@
|
||||
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl
|
||||
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl, QTimer
|
||||
from PyQt5.QtGui import QKeyEvent, QIcon
|
||||
# pylint: disable=no-name-in-module,import-error,useless-suppression
|
||||
from PyQt5.QtWidgets import QOpenGLWidget
|
||||
@ -32,7 +32,7 @@ from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript
|
||||
# pylint: enable=no-name-in-module,import-error,useless-suppression
|
||||
|
||||
from qutebrowser.browser import browsertab, mouse
|
||||
from qutebrowser.browser.webengine import webview, webengineelem
|
||||
from qutebrowser.browser.webengine import webview, webengineelem, tabhistory
|
||||
from qutebrowser.utils import usertypes, qtutils, log, javascript, utils
|
||||
|
||||
|
||||
@ -302,7 +302,15 @@ class WebEngineHistory(browsertab.AbstractHistory):
|
||||
return qtutils.deserialize(data, self._history)
|
||||
|
||||
def load_items(self, items):
|
||||
log.stub()
|
||||
stream, _data, cur_data = tabhistory.serialize(items)
|
||||
qtutils.deserialize_stream(stream, self._history)
|
||||
if cur_data is not None:
|
||||
if 'zoom' in cur_data:
|
||||
self._tab.zoom.set_factor(cur_data['zoom'])
|
||||
if ('scroll-pos' in cur_data and
|
||||
self._tab.scroller.pos_px() == QPoint(0, 0)):
|
||||
QTimer.singleShot(0, functools.partial(
|
||||
self._tab.scroller.to_point, cur_data['scroll-pos']))
|
||||
|
||||
|
||||
class WebEngineZoom(browsertab.AbstractZoom):
|
||||
|
@ -19,7 +19,6 @@ Feature: Going back and forward.
|
||||
- active: true
|
||||
url: http://localhost:*/data/backforward/2.txt
|
||||
|
||||
@qtwebengine_todo: FIXME why is this broken?
|
||||
Scenario: Going back in a new tab
|
||||
Given I open data/backforward/1.txt
|
||||
When I open data/backforward/2.txt
|
||||
|
@ -408,8 +408,6 @@ def compare_session(request, quteproc, expected):
|
||||
partial_compare is used, which means only the keys/values listed will be
|
||||
compared.
|
||||
"""
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
quteproc.compare_session(expected)
|
||||
|
||||
|
||||
@ -473,8 +471,6 @@ def check_open_tabs(quteproc, request, tabs):
|
||||
|
||||
It expects a list of URLs, with an optional "(active)" suffix.
|
||||
"""
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
session = quteproc.get_session()
|
||||
active_suffix = ' (active)'
|
||||
tabs = tabs.splitlines()
|
||||
@ -530,8 +526,6 @@ def _get_scroll_values(quteproc):
|
||||
@bdd.then(bdd.parsers.re(r"the page should be scrolled "
|
||||
r"(?P<direction>horizontally|vertically)"))
|
||||
def check_scrolled(request, quteproc, direction):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
x, y = _get_scroll_values(quteproc)
|
||||
if direction == 'horizontally':
|
||||
assert x != 0
|
||||
@ -543,8 +537,6 @@ def check_scrolled(request, quteproc, direction):
|
||||
|
||||
@bdd.then("the page should not be scrolled")
|
||||
def check_not_scrolled(request, quteproc):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
x, y = _get_scroll_values(quteproc)
|
||||
assert x == 0
|
||||
assert y == 0
|
||||
|
@ -24,8 +24,6 @@ bdd.scenarios('marks.feature')
|
||||
|
||||
@bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}"))
|
||||
def check_y(request, quteproc, x, y):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
data = quteproc.get_session()
|
||||
pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos']
|
||||
assert int(x) == pos['x']
|
||||
|
@ -25,9 +25,6 @@ import pytest_bdd as bdd
|
||||
bdd.scenarios('sessions.feature')
|
||||
|
||||
|
||||
pytestmark = pytest.mark.qtwebengine_todo("Sessions are not implemented")
|
||||
|
||||
|
||||
@bdd.when(bdd.parsers.parse('I have a "{name}" session file:\n{contents}'))
|
||||
def create_session_file(quteproc, name, contents):
|
||||
filename = os.path.join(quteproc.basedir, 'data', 'sessions',
|
||||
|
Loading…
Reference in New Issue
Block a user