From 908abb6566027d9d09fb7079738c3edcdd9ceb0a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Apr 2021 17:11:30 +0200 Subject: 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 --- qutebrowser/browser/webengine/notification.py | 2 +- tests/end2end/data/javascript/img/padded2.png | Bin 0 -> 5633 bytes tests/end2end/data/javascript/notifications.html | 2 ++ tests/end2end/features/notifications.feature | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/end2end/data/javascript/img/padded2.png 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 new file mode 100644 index 000000000..be3cff635 Binary files /dev/null and b/tests/end2end/data/javascript/img/padded2.png differ 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 @@ +
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 -- cgit v1.2.3-54-g00ecf