Merge remote-tracking branch 'origin/pr/2940'

This commit is contained in:
Florian Bruhin 2017-10-08 16:53:10 +02:00
commit 1d1faf8d25
8 changed files with 42 additions and 15 deletions

View File

@ -250,6 +250,7 @@ class AbstractZoom(QObject):
self._default_zoom_changed = False self._default_zoom_changed = False
self._init_neighborlist() self._init_neighborlist()
config.instance.changed.connect(self._on_config_changed) config.instance.changed.connect(self._on_config_changed)
self._zoom_factor = float(config.val.zoom.default) / 100
# # FIXME:qtwebengine is this needed? # # FIXME:qtwebengine is this needed?
# # For some reason, this signal doesn't get disconnected automatically # # 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 option in ['zoom.levels', 'zoom.default']:
if not self._default_zoom_changed: if not self._default_zoom_changed:
factor = float(config.val.zoom.default) / 100 factor = float(config.val.zoom.default) / 100
self._set_factor_internal(factor) self.set_factor(factor)
self._default_zoom_changed = False
self._init_neighborlist() self._init_neighborlist()
def _init_neighborlist(self): def _init_neighborlist(self):
@ -301,15 +301,22 @@ class AbstractZoom(QObject):
self._neighborlist.fuzzyval = int(factor * 100) self._neighborlist.fuzzyval = int(factor * 100)
if factor < 0: if factor < 0:
raise ValueError("Can't zoom to factor {}!".format(factor)) 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) self._set_factor_internal(factor)
def factor(self): def factor(self):
raise NotImplementedError return self._zoom_factor
def set_default(self): def set_default(self):
self._set_factor_internal(float(config.val.zoom.default) / 100) self._set_factor_internal(float(config.val.zoom.default) / 100)
def set_current(self):
self._set_factor_internal(self._zoom_factor)
class AbstractCaret(QObject): class AbstractCaret(QObject):
@ -754,6 +761,8 @@ class AbstractTab(QWidget):
if not self.title(): if not self.title():
self.title_changed.emit(self.url().toDisplayString()) self.title_changed.emit(self.url().toDisplayString())
self.zoom.set_current()
@pyqtSlot() @pyqtSlot()
def _on_history_trigger(self): def _on_history_trigger(self):
"""Emit add_history_item when triggered by backend-specific signal.""" """Emit add_history_item when triggered by backend-specific signal."""

View File

@ -445,9 +445,6 @@ class WebEngineZoom(browsertab.AbstractZoom):
def _set_factor_internal(self, factor): def _set_factor_internal(self, factor):
self._widget.setZoomFactor(factor) self._widget.setZoomFactor(factor)
def factor(self):
return self._widget.zoomFactor()
class WebEngineElements(browsertab.AbstractElements): class WebEngineElements(browsertab.AbstractElements):

View File

@ -378,9 +378,6 @@ class WebKitZoom(browsertab.AbstractZoom):
def _set_factor_internal(self, factor): def _set_factor_internal(self, factor):
self._widget.setZoomFactor(factor) self._widget.setZoomFactor(factor)
def factor(self):
return self._widget.zoomFactor()
class WebKitScroller(browsertab.AbstractScroller): class WebKitScroller(browsertab.AbstractScroller):

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

View File

@ -24,5 +24,6 @@ bdd.scenarios('zoom.feature')
@bdd.then(bdd.parsers.parse("the zoom should be {zoom}%")) @bdd.then(bdd.parsers.parse("the zoom should be {zoom}%"))
def check_zoom(quteproc, zoom): def check_zoom(quteproc, zoom):
data = quteproc.get_session() 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 assert abs(value - float(zoom)) < 0.0001

View File

@ -81,6 +81,17 @@ Feature: Zooming in and out
Then the message "Zoom level: 60%" should be shown Then the message "Zoom level: 60%" should be shown
And the zoom should be 60% 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 # Fixed in QtWebEngine branch
@xfail @xfail
Scenario: Zooming in with cloned tab Scenario: Zooming in with cloned tab

View File

@ -416,14 +416,17 @@ class QuteProc(testprocess.Process):
verbatim. verbatim.
""" """
special_schemes = ['about:', 'qute:', 'chrome:', 'view-source:', 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): if any(path.startswith(scheme) for scheme in special_schemes):
path = path.replace('(port)', str(server_port))
return path return path
else: else:
server = self.request.getfixturevalue('server')
return '{}://localhost:{}/{}'.format( return '{}://localhost:{}/{}'.format(
'https' if https else 'http', 'https' if https else 'http',
server.port if port is None else port, server_port,
path if path != '/' else '') path if path != '/' else '')
def wait_for_js(self, message): def wait_for_js(self, message):

View File

@ -73,7 +73,7 @@ def redirect_later():
If delay is -1, wait until a request on redirect-later-continue is done. If delay is -1, wait until a request on redirect-later-continue is done.
""" """
global _redirect_later_event global _redirect_later_event
delay = int(flask.request.args.get('delay', '1')) delay = float(flask.request.args.get('delay', '1'))
if delay == -1: if delay == -1:
_redirect_later_event = threading.Event() _redirect_later_event = threading.Event()
ok = _redirect_later_event.wait(timeout=30 * 1000) ok = _redirect_later_event.wait(timeout=30 * 1000)