diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-04-09 17:11:30 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-04-09 17:14:26 +0200 |
commit | 908abb6566027d9d09fb7079738c3edcdd9ceb0a (patch) | |
tree | f16f408adc37a11dfa3fa5c0e463f881dd515d47 | |
parent | dc14d314c424a8d9ddf2e8e8c98d6d663e26cf38 (diff) | |
download | qutebrowser-908abb6566027d9d09fb7079738c3edcdd9ceb0a.tar.gz qutebrowser-908abb6566027d9d09fb7079738c3edcdd9ceb0a.zip |
notifications: Fix image padding assertion
The underlying Chromium pads images so that scanlines align on 4-byte
boundaries. Thus, with an image size of e.g. 239x239, we'll have 3 bytes
of padding (239 mod 4 = 3; 240 mod 4 = 0).
Fixes #6375
-rw-r--r-- | qutebrowser/browser/webengine/notification.py | 2 | ||||
-rw-r--r-- | tests/end2end/data/javascript/img/padded2.png | bin | 0 -> 5633 bytes | |||
-rw-r--r-- | tests/end2end/data/javascript/notifications.html | 2 | ||||
-rw-r--r-- | tests/end2end/features/notifications.feature | 6 |
4 files changed, 9 insertions, 1 deletions
diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py index 682d64bdc..36493f4f7 100644 --- a/qutebrowser/browser/webengine/notification.py +++ b/qutebrowser/browser/webengine/notification.py @@ -1029,7 +1029,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter): # Source: # https://github.com/dunst-project/dunst/blob/v1.6.1/src/icon.c#L292-L309 padding = bytes_per_line - width * channel_count - assert 0 <= padding < 3, (padding, bytes_per_line, width, channel_count) + assert 0 <= padding <= 3, (padding, bytes_per_line, width, channel_count) size -= padding if padding and self._quirks.no_padded_images: diff --git a/tests/end2end/data/javascript/img/padded2.png b/tests/end2end/data/javascript/img/padded2.png Binary files differnew file mode 100644 index 000000000..be3cff635 --- /dev/null +++ b/tests/end2end/data/javascript/img/padded2.png diff --git a/tests/end2end/data/javascript/notifications.html b/tests/end2end/data/javascript/notifications.html index db28328d5..2c4590417 100644 --- a/tests/end2end/data/javascript/notifications.html +++ b/tests/end2end/data/javascript/notifications.html @@ -101,6 +101,8 @@ <input type="button" onclick="show_image_notification('RGB', 'rgb.png')" value="Show image notification without alpha channel" id="show-image-button-noalpha"> <input type="button" onclick="show_image_notification('Big', 'big.png')" value="Show a big image notification" id="show-image-button-big"> <input type="button" onclick="show_image_notification('Padded', 'padded.png')" value="Show a padded image notification" id="show-image-button-padded"> + <input type="button" onclick="show_image_notification('Padded 2', 'padded2.png')" value="Show a padded image notification 2" +id="show-image-button-padded-2"> </div> <div> More advanced test pages: diff --git a/tests/end2end/features/notifications.feature b/tests/end2end/features/notifications.feature index 5da0c072e..08c5f725f 100644 --- a/tests/end2end/features/notifications.feature +++ b/tests/end2end/features/notifications.feature @@ -53,6 +53,12 @@ Feature: Notifications And the notification should have title "Padded" And the notification should have image dimensions 46x46 + Scenario: Notification with padded image 2 + When I run :click-element id show-image-button-padded-2 + Then the javascript message "notification shown" should be logged + And the notification should have title "Padded 2" + And the notification should have image dimensions 239x239 + Scenario: Closing notification via web When I run :click-element id show-closing-button Then the javascript message "notification shown" should be logged |