Closed Bug 860951 Opened 11 years ago Closed 11 years ago

\n in XUL alert text doesn't create a newline

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla24
Tracking Status
firefox21 --- unaffected
firefox22 + fixed
firefox23 + verified

People

(Reporter: reuben, Assigned: reuben)

References

Details

(Keywords: regression)

Attachments

(1 file)

Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService).showAlertNotification(null, "Title", "Foo\nBar");

Actual results:
Foo Bar

Expected results:
Foo
Bar
OS: All → Mac OS X
Seeing this on Windows 7, too.
Blocks: 782211
Keywords: regression
OS: Mac OS X → All
Assignee: nobody → wchen
The reason this happens is because the XUL alerts use a <xul:label> for the text of the alert and it doesn't support newlines. This isn't a regression, it's been that way in the XUL alerts since hg 1 so I'm not sure this bug should be tracked. If we do want to allow new lines in alerts, then I think this bug would be better assigned to someone with more XUL experience.
(In reply to William Chen [:wchen] from comment #2)
> The reason this happens is because the XUL alerts use a <xul:label> for the
> text of the alert and it doesn't support newlines. This isn't a regression,
> it's been that way in the XUL alerts since hg 1 so I'm not sure this bug
> should be tracked. If we do want to allow new lines in alerts, then I think
> this bug would be better assigned to someone with more XUL experience.

This is a regression in notifications. I can reword the bug title, but the underlying problem is still the same: newlines used to work, and now they don't.

Can't we use something else instead of a <xul:label>?
I think we may just need to set the |whitespace: pre;| CSS style on the label.
Actually, that should be |white-space: pre-wrap;|
<Unfocused> such a beautiful bromance

Why don't you play a part in this heartwarming story?
Attachment #753515 - Flags: review?(bmcbride)
Attachment #753515 - Flags: review?(bmcbride) → review+
Oops, that file uses 2 space indentation.

https://hg.mozilla.org/integration/mozilla-inbound/rev/d9cf9e32f267
https://hg.mozilla.org/mozilla-central/rev/0134d330663f
https://hg.mozilla.org/mozilla-central/rev/d9cf9e32f267
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Would you mind requesting uplift to Aurora/Beta to make sure this is resolved in FF23, preventing a regression?
Comment on attachment 753515 [details] [diff] [review]
Add white-space: pre-wrap; to alert text

[Approval Request Comment]
Bug caused by (feature/regressing bug #): bug 782211
User impact if declined: multi-line notifications shown in a single line
Testing completed (on m-c, etc.): Landed on m-c a week ago, no problems have surfaced
Risk to taking this patch (and alternatives if risky): None
String or IDL/UUID changes made by this patch: None
Attachment #753515 - Flags: approval-mozilla-beta?
Attachment #753515 - Flags: approval-mozilla-aurora?
Attachment #753515 - Flags: approval-mozilla-beta?
Attachment #753515 - Flags: approval-mozilla-beta+
Attachment #753515 - Flags: approval-mozilla-aurora?
Attachment #753515 - Flags: approval-mozilla-aurora+
Is there anything QA can do here?
Keywords: verifyme
Can you please give me some examples of notifications with which I could reproduce/verify this bug?
Flags: needinfo?(reuben.bmo)
(In reply to Ioana Budnar, QA [:ioana] from comment #15)
> Can you please give me some examples of notifications with which I could
> reproduce/verify this bug?

Open the browser console (Ctrl/Cmd+Shift+J), paste the text from comment 0 and press enter:
  Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService).showAlertNotification(null, "Title", "Foo\nBar");

You should see three separate lines of text in the notification: "Title", "Foo" and "Bar".
Flags: needinfo?(reuben.bmo)
I thought there was some other way. I tried with the Error Console and Web Console and I got "ReferenceError: Cc is not defined".

Firefox 23 doesn't have the Browser Console.
You can also flip the "devtools.chrome.enabled" pref to true, and then run that code in Scratchpad, with the Browser environment.
Hm, WebNotifications landed in 22, so alternatively you can also do this in the page console or scratchpad:

Notification.requestPermission();
*Allow notifications using the doorhanger popup*
new Notification("Title", { body: "Foo\nBar" });
(In reply to Reuben Morais [:reuben] from comment #19)
> Hm, WebNotifications landed in 22, so alternatively you can also do this in
> the page console or scratchpad:
> 
> Notification.requestPermission();
> *Allow notifications using the doorhanger popup*
> new Notification("Title", { body: "Foo\nBar" });

Thanks for all the help Reuben. I verified this as fixed on Firefox 23 beta 10 (20130729175331), Ubuntu 13.04 32bit and Windows 7 64bit.

I tried to verify it on Mac OSX 10.7, but there's no notification shown there for some reason. Is this a known issue, or somehow designed to work differently on Mac?
(In reply to Ioana Budnar, QA [:ioana] from comment #20)
> I tried to verify it on Mac OSX 10.7, but there's no notification shown
> there for some reason. Is this a known issue, or somehow designed to work
> differently on Mac?

I don't think so. Can you check if you have Growl installed/runnning, and in that case, if closing it makes any difference? If no notifications show up, please file a new bug under Core :: Widget: Cocoa. Thanks for the help!
There was some Growl framework that came with the OS, but no app/pane/options to work with it. I didn't find anything related to it in the running processes list either. => Notifications didn't work at all.

Installed Growl 1.2.2 and let it run => Notifications didn't work.

Stopped Growl => Some notifications were displayed (new Notification("Title", { body: "Foo\nBar" });), but very few.

Removed Growl => Notifications didn't work.

Reinstalled Growl => Notification didn't work with Growl on, nor off.

Same behavior on Firefox 23 RC, 24 Aurora and 25 Nightly.

What are the expected results here?
I don't believe this bug was specific to Growl but the native OS notification on all platforms. Comment 0 has a fairly clear testcase. If that doesn't work then please need-info Rueben.

Note that testing with Growl is a moot point since we dropped support for it in Firefox 22 (bug 777409).
(In reply to Anthony Hughes, Mozilla QA (:ashughes) from comment #23)
> I don't believe this bug was specific to Growl but the native OS
> notification on all platforms. Comment 0 has a fairly clear testcase. If
> that doesn't work then please need-info Rueben.
> 
> Note that testing with Growl is a moot point since we dropped support for it
> in Firefox 22 (bug 777409).

Comment 22 was an answer to Reuben's previous comment, where I was asked to also check how Growl affects this. I am waiting for him to confirm what the issue is here.
Flags: needinfo?(reuben.bmo)
I asked you to test if Growl affects WebNotifications because that would be a Widget: Cocoa bug, given bug 777409. I'll look into it and file bugs if necessary. Thanks Ioana!
Flags: needinfo?(reuben.bmo)
Status: RESOLVED → VERIFIED
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: