Merge remote-tracking branch 'origin/pr/2940'
This commit is contained in:
commit
1d1faf8d25
@ -250,6 +250,7 @@ class AbstractZoom(QObject):
|
||||
self._default_zoom_changed = False
|
||||
self._init_neighborlist()
|
||||
config.instance.changed.connect(self._on_config_changed)
|
||||
self._zoom_factor = float(config.val.zoom.default) / 100
|
||||
|
||||
# # FIXME:qtwebengine is this needed?
|
||||
# # For some reason, this signal doesn't get disconnected automatically
|
||||
@ -263,8 +264,7 @@ class AbstractZoom(QObject):
|
||||
if option in ['zoom.levels', 'zoom.default']:
|
||||
if not self._default_zoom_changed:
|
||||
factor = float(config.val.zoom.default) / 100
|
||||
self._set_factor_internal(factor)
|
||||
self._default_zoom_changed = False
|
||||
self.set_factor(factor)
|
||||
self._init_neighborlist()
|
||||
|
||||
def _init_neighborlist(self):
|
||||
@ -301,15 +301,22 @@ class AbstractZoom(QObject):
|
||||
self._neighborlist.fuzzyval = int(factor * 100)
|
||||
if factor < 0:
|
||||
raise ValueError("Can't zoom to factor {}!".format(factor))
|
||||
self._default_zoom_changed = True
|
||||
|
||||
default_zoom_factor = float(config.val.zoom.default) / 100
|
||||
self._default_zoom_changed = (factor != default_zoom_factor)
|
||||
|
||||
self._zoom_factor = factor
|
||||
self._set_factor_internal(factor)
|
||||
|
||||
def factor(self):
|
||||
raise NotImplementedError
|
||||
return self._zoom_factor
|
||||
|
||||
def set_default(self):
|
||||
self._set_factor_internal(float(config.val.zoom.default) / 100)
|
||||
|
||||
def set_current(self):
|
||||
self._set_factor_internal(self._zoom_factor)
|
||||
|
||||
|
||||
class AbstractCaret(QObject):
|
||||
|
||||
@ -754,6 +761,8 @@ class AbstractTab(QWidget):
|
||||
if not self.title():
|
||||
self.title_changed.emit(self.url().toDisplayString())
|
||||
|
||||
self.zoom.set_current()
|
||||
|
||||
@pyqtSlot()
|
||||
def _on_history_trigger(self):
|
||||
"""Emit add_history_item when triggered by backend-specific signal."""
|
||||
|
@ -445,9 +445,6 @@ class WebEngineZoom(browsertab.AbstractZoom):
|
||||
def _set_factor_internal(self, factor):
|
||||
self._widget.setZoomFactor(factor)
|
||||
|
||||
def factor(self):
|
||||
return self._widget.zoomFactor()
|
||||
|
||||
|
||||
class WebEngineElements(browsertab.AbstractElements):
|
||||
|
||||
|
@ -378,9 +378,6 @@ class WebKitZoom(browsertab.AbstractZoom):
|
||||
def _set_factor_internal(self, factor):
|
||||
self._widget.setZoomFactor(factor)
|
||||
|
||||
def factor(self):
|
||||
return self._widget.zoomFactor()
|
||||
|
||||
|
||||
class WebKitScroller(browsertab.AbstractScroller):
|
||||
|
||||
|
9
tests/end2end/data/long_load.html
Normal file
9
tests/end2end/data/long_load.html
Normal file
@ -0,0 +1,9 @@
|
||||
<script type="text/javascript">
|
||||
var date = new Date();
|
||||
var curDate = new Date();
|
||||
while(curDate-date < 2000) {
|
||||
curDate = new Date();
|
||||
};
|
||||
|
||||
document.write("<html><h1>hello</h1></html>");
|
||||
</script>
|
@ -24,5 +24,6 @@ bdd.scenarios('zoom.feature')
|
||||
@bdd.then(bdd.parsers.parse("the zoom should be {zoom}%"))
|
||||
def check_zoom(quteproc, zoom):
|
||||
data = quteproc.get_session()
|
||||
value = data['windows'][0]['tabs'][0]['history'][0]['zoom'] * 100
|
||||
histories = data['windows'][0]['tabs'][0]['history']
|
||||
value = next(h for h in histories if 'zoom' in h)['zoom'] * 100
|
||||
assert abs(value - float(zoom)) < 0.0001
|
||||
|
@ -81,6 +81,17 @@ Feature: Zooming in and out
|
||||
Then the message "Zoom level: 60%" should be shown
|
||||
And the zoom should be 60%
|
||||
|
||||
# https://github.com/qutebrowser/qutebrowser/issues/2507
|
||||
# Using 127.0.0.1 because separate domain is required to reproduce
|
||||
Scenario: Qutebrowser enforces correct zoom level
|
||||
When I run :zoom 150%
|
||||
And I open data/search.html
|
||||
And I run :open http://127.0.0.1:(port)/data/long_load.html
|
||||
And I wait until http://127.0.0.1:(port)/data/long_load.html is loaded
|
||||
And I run :back
|
||||
And I wait until data/search.html is loaded
|
||||
Then the zoom should be 150%
|
||||
|
||||
# Fixed in QtWebEngine branch
|
||||
@xfail
|
||||
Scenario: Zooming in with cloned tab
|
||||
|
@ -416,14 +416,17 @@ class QuteProc(testprocess.Process):
|
||||
verbatim.
|
||||
"""
|
||||
special_schemes = ['about:', 'qute:', 'chrome:', 'view-source:',
|
||||
'data:']
|
||||
'data:', 'http:', 'https:']
|
||||
server = self.request.getfixturevalue('server')
|
||||
server_port = server.port if port is None else port
|
||||
|
||||
if any(path.startswith(scheme) for scheme in special_schemes):
|
||||
path = path.replace('(port)', str(server_port))
|
||||
return path
|
||||
else:
|
||||
server = self.request.getfixturevalue('server')
|
||||
return '{}://localhost:{}/{}'.format(
|
||||
'https' if https else 'http',
|
||||
server.port if port is None else port,
|
||||
server_port,
|
||||
path if path != '/' else '')
|
||||
|
||||
def wait_for_js(self, message):
|
||||
|
@ -73,7 +73,7 @@ def redirect_later():
|
||||
If delay is -1, wait until a request on redirect-later-continue is done.
|
||||
"""
|
||||
global _redirect_later_event
|
||||
delay = int(flask.request.args.get('delay', '1'))
|
||||
delay = float(flask.request.args.get('delay', '1'))
|
||||
if delay == -1:
|
||||
_redirect_later_event = threading.Event()
|
||||
ok = _redirect_later_event.wait(timeout=30 * 1000)
|
||||
|
Loading…
Reference in New Issue
Block a user