Closed
Bug 1213421
Opened 9 years ago
Closed 9 years ago
Setting long body text in notification causes text to wrap
Categories
(Toolkit Graveyard :: Notifications and Alerts, defect)
Tracking
(firefox44 fixed, firefox45 fixed, b2g-v2.5 fixed)
RESOLVED
FIXED
mozilla45
People
(Reporter: pdehaan, Assigned: jaws)
References
Details
(Keywords: sec-low, Whiteboard: [adv-main44+])
Attachments
(5 files, 2 obsolete files)
68.63 KB,
image/png
|
Details | |
3.90 KB,
patch
|
MattN
:
review+
|
Details | Diff | Splinter Review |
2.26 KB,
patch
|
MattN
:
review+
|
Details | Diff | Splinter Review |
2.75 KB,
patch
|
MattN
:
review+
|
Details | Diff | Splinter Review |
6.44 KB,
patch
|
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
Steps to reproduce: 0. Use Windows (tested on Win 10). 1. https://people.mozilla.org/~ewong2/push-notification-test/ 2. Set a long title and body text. 3. Push "pop Notification" button. Actual results: see screenshot. Expected results: truncate the text (similar to what we do in OS X).
Reporter | ||
Comment 1•9 years ago
|
||
It looks like if your body string doesn't have linebreaks, then the notification grows very wide and unmanageable. Similarly, if your title is long, it doesn't truncate or wrap on Windows (where it truncates on OS X).
Assignee | ||
Comment 2•9 years ago
|
||
The title now wraps on Windows and Linux as of bug 1201397. As for truncating, I worry that we will be over-engineering a solution here. The notification was implemented in a way that it expands to show the notification text without overflowing the containers or otherwise looking broken (besides looking somewhat "large"). We should WONTFIX this bug, and rely on websites to provide a proper user experience for their users. Sites like Facebook and Gmail will not place tons of text in their notification because it will not be readable in the timeout provided. As sites need to get permission before notifications can be shown, and the ability to revoke the permission directly from the notification, bad actors are sufficiently dissuaded. Further, there may be a good use-case for longer than anticipated text within the notification that we may not know of today.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Comment 3•9 years ago
|
||
(In reply to Jared Wein [:jaws] (please needinfo? me) from comment #2) > and the ability to revoke the permission directly from the > notification, bad actors are sufficiently dissuaded. Do we enforce that the popup isn't vertically larger than the screen so that the gear and [X] are both displayed? Spammers have used tricks like that for window.alert(…) before. I think putting some high cap could be useful if websites make mistakes and send un-truncated text and so the controls of at least one notification are fully visible. If text-overflow:ellipsis just worked on multi-line text then this would be fairly straightforward. A hack with a gradient for a solid background notification could also work.
Assignee | ||
Comment 4•9 years ago
|
||
Truncating to 1000 characters would be fine with me, but this starts getting complicated as we would have to start worrying about various resolutions if we want to guarantee that the gear and [X] are visible on-screen (640x480 for example). This is not the same problem as window.alert since the website has to get permission first. While true that a bug on the website may cause more text to get displayed than intended, there is very low drive-by probability and the alert auto-closes.
Comment 6•9 years ago
|
||
:phlsa to provide character limits
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Comment 7•9 years ago
|
||
I played around with this for a little and 200 chars seems to be a good character limit for the body that can still largely be read in the time a notification shows up. The title should just have overflow:ellipsis so that it never shows more than one line.
Flags: needinfo?(philipp)
Comment 9•9 years ago
|
||
sec-low from bug 1220519 (probably due to DOS)
Status: REOPENED → NEW
Keywords: sec-low
Assignee | ||
Comment 10•9 years ago
|
||
I didn't add an ellipsis to the truncation of the body text since label[crop=end] doesn't support multiline text and neither does text-overflow:ellipsis. I didn't add a new string like "%S ..." because we want to get this patch uplifted and this will break string freeze. We can do a follow-up that will not get uplifted but will include the ellipsis using the stringbundle approach.
Assignee | ||
Comment 11•9 years ago
|
||
It turns out that nsContextMenu does something similar for the "Seach engineName for '%S...'" string, so I copied that code over to alert.js to put an ellipsis in the body text. See http://mxr.mozilla.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1782 I tested the context menu code in a Hebrew build and confirmed that it works with RTL text.
Attachment #8684918 -
Attachment is obsolete: true
Attachment #8684918 -
Flags: review?(MattN+bmo)
Attachment #8684949 -
Flags: review?(MattN+bmo)
Assignee | ||
Updated•9 years ago
|
Summary: Setting long body text in notification causes text to wrap on Win 10 → Setting long body text in notification causes text to wrap
Comment 12•9 years ago
|
||
Comment on attachment 8684949 [details] [diff] [review] Patch v2 Review of attachment 8684949 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/alerts/resources/content/alert.js @@ +10,5 @@ > const NS_ALERT_TOP = 4; > > const WINDOW_MARGIN = 10; > > +const BODY_TEXT_LIMIT = 200; Nit: group this with WINDOW_MARGIN and sort alphabetically since I don't think this will get grouped with anything related. @@ +108,5 @@ > + // If the JS character after our truncation point is a trail surrogate, > + // include it in the truncated string to avoid splitting a surrogate pair. > + let truncLength = BODY_TEXT_LIMIT; > + let truncChar = bodyText[BODY_TEXT_LIMIT].charCodeAt(0); > + if (truncChar >= 0xDC00 && truncChar <= 0xDFFF) { Seems like this would be nice in a helper but I don't know where would be good off-hand. At a minimum there should be a comment that this was copied from nsContextMenu and ideally a comment there pointing here too. @@ +115,5 @@ > + bodyTextLabel.textContent = bodyText.substring(0, BODY_TEXT_LIMIT) + > + ellipsis; > + } > + > + if (bodyText.length > BODY_TEXT_LIMIT) { Why not fold this into the `if` body above for the same condition?
Attachment #8684949 -
Flags: review?(MattN+bmo) → review+
Assignee | ||
Comment 13•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/697fb66c4494f8df72f4e8e5e97d7b842e0a0cfe Bug 1213421 - Truncate long body and title text in notifications. r=MattN
Assignee | ||
Comment 14•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/3d8143254eac173858c97f6e0d3ae9a48be3dcbc Bug 1213421 - Follow-up, set the bodyText even when text is not being truncated. r=MattN
Assignee | ||
Comment 15•9 years ago
|
||
I just noticed this in my local build. Pushed it so it wouldn't break the next weekday Nightly build.
Attachment #8687566 -
Flags: review?(MattN+bmo)
Comment 16•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/697fb66c4494 https://hg.mozilla.org/mozilla-central/rev/3d8143254eac
Status: ASSIGNED → RESOLVED
Closed: 9 years ago → 9 years ago
status-firefox45:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Comment 17•9 years ago
|
||
Comment on attachment 8687566 [details] [diff] [review] Follow-up Review of attachment 8687566 [details] [diff] [review]: ----------------------------------------------------------------- We should probably have a simple test for this (in a follow-up) if we don't already.
Attachment #8687566 -
Flags: review?(MattN+bmo) → review+
Assignee | ||
Comment 18•9 years ago
|
||
Wasn't sure if you wanted a separate bug, but the patch is quite simple so I just kept it in this bug.
Attachment #8689181 -
Flags: review?(MattN+bmo)
Comment 19•9 years ago
|
||
Comment on attachment 8689181 [details] [diff] [review] Follow-up with tests for title, body, and image Review of attachment 8689181 [details] [diff] [review]: ----------------------------------------------------------------- It's okay here since the first part wasn't uplifted yet. Can you request uplift on both?
Attachment #8689181 -
Flags: review?(MattN+bmo) → review+
Assignee | ||
Comment 20•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/24c5d435977da94d3986c89085496d8ddef6f1b2 Bug 1213421 - Add a test that verifies the body text of a notification is present. r=MattN
Assignee | ||
Comment 21•9 years ago
|
||
Approval Request Comment [Feature/regressing bug #]: new feature work for push/desktop notifications [User impact if declined]: push notifications will look too large if sites send too much text for them [Describe test coverage new/current, TreeHerder]: automated tests and manual testing [Risks and why]: low risk, been on nightly for a few days now with heavy QA testing [String/UUID change made/needed]: none
Attachment #8689500 -
Flags: approval-mozilla-aurora?
Comment 22•9 years ago
|
||
sorry had to back this out for surfacing leaks like https://treeherder.mozilla.org/logviewer.html#?job_id=5811620&repo=fx-team that started with this push
Flags: needinfo?(jaws)
Comment 23•9 years ago
|
||
Backout: https://hg.mozilla.org/integration/fx-team/rev/9a49075671cb
Comment on attachment 8689500 [details] [diff] [review] Roll-up patch for Aurora44 Please re-nominate for uplift once the reasons for backout from fx are fixed and addressed.
Attachment #8689500 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora-
Assignee | ||
Comment 25•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/d516d82f29a2636c5834c7f3c932025b8e85a8ad Bug 1213421 - Add a test that verifies the text of a notification is present. r=MattN
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(jaws)
Comment 26•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d516d82f29a2
Assignee | ||
Comment 27•9 years ago
|
||
Approval Request Comment [Feature/regressing bug #]: new feature work for push/desktop notifications [User impact if declined]: push notifications will look too large if sites send too much text for them [Describe test coverage new/current, TreeHerder]: automated tests and manual testing [Risks and why]: low risk, been on nightly for a few days now with heavy QA testing [String/UUID change made/needed]: none
Attachment #8689500 -
Attachment is obsolete: true
Attachment #8691980 -
Flags: approval-mozilla-aurora?
Comment on attachment 8691980 [details] [diff] [review] Roll-up patch for Aurora44 v2 Push notifications is planned for FF44 and this fix has been in Nightly for a few days now, seems safe to uplift to Aurora44.
Attachment #8691980 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 29•9 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-aurora/rev/ea94de8a09f0
Comment 30•9 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/ea94de8a09f0
status-b2g-v2.5:
--- → fixed
Updated•8 years ago
|
Whiteboard: [adv-main44+]
Updated•10 months ago
|
Product: Toolkit → Toolkit Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•