Closed Bug 964412 Opened 6 years ago Closed 5 years ago

Support basic HTML markup in doorhanger text

Categories

(Firefox for Android :: General, defect)

ARM
Android
defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 38
Tracking Status
firefox38 --- fixed

People

(Reporter: mkaply, Assigned: AndyP, Mentored)

Details

(Whiteboard: [lang=java])

Attachments

(2 files)

Similar to bug 959880 for the home banner text, we should support basic HTML markup in door hangers.
This may be difficult to implement, given that this is a native dialog.
Even if implemented, the set of tags that are allowed should be extremely restricted, basically just the semantic HTML set like <li>, <h1>, <em>, <strong> etc., and maybe <a href="">, but only with simple, checked link targets.

Furthermore, formatted text should be explicitly enabled by the caller (default needs to be plaintext), and callers should take care not to pass untrusted data there.
This should actually be pretty easy with Html.fromHtml. The API should take care of sanitizing the data for us.
Whiteboard: [mentor=margaret][lang=java]
Mentor: margaret.leibovic
Whiteboard: [mentor=margaret][lang=java] → [lang=java]
I'd be interested in working on this but I'll need more info. Could you tell me what these door hangers are and which files might be affected?
(In reply to Andy Pusch from comment #3)
> I'd be interested in working on this but I'll need more info. Could you tell
> me what these door hangers are and which files might be affected?

Hi Andy! "Doorhangers" is a term we use to describe the popup notifications that hang off the browser toolbar. Firefox itself will create these notifications for things like a site requesting to use your location, but add-ons can also create them. See:
https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/NativeWindow/doorhanger

You'll want to look into changing the Doorhanger#setMessage method declared here:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/widget/DoorHanger.java#162

To test this, I would make an add-on that uses some HTML mark-up in a doorhanger message. You can just modify this add-on:
https://github.com/mozilla/firefox-for-android-addons/tree/master/boilerplate/native-ui-boilerplate

It already even includes a doorhanger API call:
https://github.com/mozilla/firefox-for-android-addons/blob/master/boilerplate/native-ui-boilerplate/bootstrap.js#L24
Attachment #8561109 - Flags: review?(margaret.leibovic)
Attached image doorHangerTest.png
HTML markup test screenshot.
Assignee: nobody → drag
Comment on attachment 8561109 [details] [diff] [review]
bug964412_BasicHTMLMarkupInDoorHangers.diff

Review of attachment 8561109 [details] [diff] [review]:
-----------------------------------------------------------------

Nice! Thanks for the screenshot, looks like you did a good job testing :)

It looks like subtext/supertext don't work well, but that's probably an edgecase we don't really need to support.
Attachment #8561109 - Flags: review?(margaret.leibovic) → review+
Here is the try link, I hope the settings are alright. :)

https://treeherder.mozilla.org/#/jobs?repo=try&revision=c32e27e4f3bf
(In reply to Andy Pusch from comment #8)
> Here is the try link, I hope the settings are alright. :)
> 
> https://treeherder.mozilla.org/#/jobs?repo=try&revision=c32e27e4f3bf

Awesome, that's perfect!

This is looking good so far, you can add the checkin-needed keyword to the bug once the test runs finish (and look green).
There are 2 busted and 1 failed. I don't know if this is relevant to my changes, could you please look at it?
Flags: needinfo?(margaret.leibovic)
(In reply to Andy Pusch from comment #10)
> There are 2 busted and 1 failed. I don't know if this is relevant to my
> changes, could you please look at it?

They don't look related, and the busted ones actually passed on a re-try. So you're good to go!
Flags: needinfo?(margaret.leibovic)
Keywords: checkin-needed
https://hg.mozilla.org/integration/fx-team/rev/23c7c953aab4
Keywords: checkin-needed
Whiteboard: [lang=java] → [lang=java][fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/23c7c953aab4
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Whiteboard: [lang=java][fixed-in-fx-team] → [lang=java]
Target Milestone: --- → Firefox 38
You need to log in before you can comment on or make changes to this bug.