Closed Bug 850297 Opened 11 years ago Closed 11 years ago

Allow jetpack addons to use the console API with the web console

Categories

(DevTools :: Console, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: msucan, Assigned: msucan)

References

Details

Attachments

(1 file)

Jetpack includes code to output plain text messages to the error console and it also dumps those messages into the virtual terminal.

We need to allow jetpack addons to use their console API implementation and output to the web console. Messages only need to show in the Browser Console - see bug 587757.
Blocks: 850296
Attached patch proof of conceptSplinter Review
Panos: this patch, plus the minimal patch that Alex did for the addon SDK, allows jetpack authors to call console.log("foo", fooObject), and the message goes into the web console output.

This is a working proof of concept patch that makes all of the open web consoles to show the messages from all addons.

I added the Browser Console as a dependency: once we have the global console UI, we can trivially filter out messages coming from jetpack, so they only show in the browser console. As I understand, the jetpack team would be happy if we can land something that works.

Concerns with the proof of concept patch:

1. This is a new notification specific for the addon SDK. Ideally, we should reuse the console-api-log-event notification. We can almost do that, but I am not sure if we want that, really. The message ID property holds the outer window ID. For jetpacks we can use the addon ID, as alex did in his proof of concept patch. We can just leave inner ID undefined.

The browser console ignores the IDs, so we show all of the console API messages. Once we add logic for addon contexts, we'll be able to add UI to filter messages specific to the addon you select.

Thoughts? Should we reuse the console-api-log-event here?

2. With minimal changes in the addon sdk, the console API calls can be cached, so they can show later when the user opens the browser console. ConsoleAPIStorage.jsm can be imported and the new message can be recorded. Would that be fine?

3. The addon SDK includes its own console API implementation. Some day it might make sense to make ConsoleAPI.js easier to reuse. I believe that's for a different bug. Any thoughts?

Thanks!
Attachment #724062 - Flags: feedback?(past)
Comment on attachment 724062 [details] [diff] [review]
proof of concept

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

I agree with everything you say!
Attachment #724062 - Flags: feedback?(past) → feedback+
Alexandre: I am marking this bug as WFM. We landed the Browser Console, bug 587757, and we also made changes to Console.jsm such that any console API call shows in the Browser Console as well, see bug 851231. We will soon replace the Error Console with the Browser Console.

At this point the addon sdk should be able to simply import Console.jsm and expose it to jetpack addons. If there's still something preventing you from doing that, please let us know - open bug reports as needed.

I also have a working patch for adding the |console| object to all JavaScript Modules, by default, without any need to do Cu.import(). That one is only pending reviews.

Thank you!
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: