Don't accept floats for :scroll-px.

This commit is contained in:
Florian Bruhin 2015-11-17 06:50:27 +01:00
parent 71134f97e3
commit 40e2258ef3
3 changed files with 17 additions and 5 deletions

View File

@ -68,6 +68,7 @@ Changed
finished. When set to `-1`, downloads are never removed.
- The `:follow-hint` command now optionally takes the keystring of a hint to
follow.
- `:scroll-px` now doesn't take floats anymore, which made little sense.
Deprecated
~~~~~~~~~~

View File

@ -521,7 +521,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', hide=True,
scope='window', count='count')
def scroll_px(self, dx: {'type': float}, dy: {'type': float}, count=1):
def scroll_px(self, dx: {'type': int}, dy: {'type': int}, count=1):
"""Scroll the current tab by 'count * dx/dy' pixels.
Args:
@ -538,8 +538,8 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', hide=True,
scope='window', count='count')
def scroll(self,
direction: {'type': (str, float)},
dy: {'type': float, 'hide': True}=None,
direction: {'type': (str, int)},
dy: {'type': int, 'hide': True}=None,
count=1):
"""Scroll the current tab in the given direction.
@ -552,8 +552,8 @@ class CommandDispatcher:
# pylint: disable=too-many-locals
try:
# Check for deprecated dx/dy form (like with scroll-px).
dx = float(direction)
dy = float(dy)
dx = int(direction)
dy = int(dy)
except (ValueError, TypeError):
# Invalid values will get handled later.
pass

View File

@ -46,6 +46,12 @@ Feature: Scrolling
And I run :scroll-px 10 10
Then no crash should happen
Scenario: :scroll-px with floats
# This used to be allowed, but doesn't make much sense.
When I run :scroll-px 2.5 2.5
Then the error "scroll-px: Argument dx: invalid int value: '2.5'" should be shown.
And the page should not be scrolled.
## :scroll
Scenario: Scrolling down
@ -94,6 +100,11 @@ Feature: Scrolling
Then the warning ":scroll with dx/dy arguments is deprecated - use :scroll-px instead!" should be shown.
Then the page should be scrolled vertically.
Scenario: :scroll with deprecated pixel argument (float)
When I run :scroll 2.5 2.5
Then the error "scroll: Argument dy: invalid int value: '2.5'" should be shown.
And the page should not be scrolled.
Scenario: Scrolling down and up with count
When I run :scroll down with count 2
And I run :scroll up