Web Extension API to listen console log messages
Categories
(WebExtensions :: Developer Tools, enhancement, P5)
Tracking
(Not tracked)
People
(Reporter: kabilan.vk, Unassigned)
References
Details
(Whiteboard: [design-decision-approved][dev-ux])
Attachments
(1 obsolete file)
Updated•8 years ago
|
Comment 1•8 years ago
|
||
Updated•8 years ago
|
| Reporter | ||
Comment 2•8 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•7 years ago
|
Updated•3 years ago
|
Comment 3•2 years ago
|
||
This is design-decision-approved but it's been a long time so I'll ask.
If I implemented this, would the patch be accepted? I'm imagining something like browser.devtools.console with events for each of the categories in devtools like onError, onWarning, onInfo, onDebug.
What do you think?
| Reporter | ||
Comment 4•2 years ago
|
||
The request is to listen to console messages from a script. If those (onError, onWarning, onInfo, onDebug) APIs are supported for listening that's good.
Comment 5•2 years ago
|
||
(In reply to Gregory Pappas [:gregp] from comment #3)
This is design-decision-approved but it's been a long time so I'll ask.
If I implemented this, would the patch be accepted? I'm imagining something like
browser.devtools.consolewith events for each of the categories in devtools likeonError,onWarning,onInfo,onDebug.What do you think?
Are there current use cases that cannot be addressed with the existing alternatives?
Automation tools can already use the CDP and subscribe to Runtime.consoleAPICalled messages. This was implemented in bug 1553854.
Firefox does not support the chrome.debugger API that enables extensions to connect through the CDP. But extensions can already intercept console.log, etc. calls by using a content script that override the console API. It is also possible to catch uncaught errors through the window.onerror and window.onunhandledrejection events.
Comment 6•2 years ago
|
||
Please note that we should no longer propose to use any CDP API with Firefox. Instead our WebDriver BiDi implementation should be utilized and listening for logs can easily be done by subscribing to the log.entryAdded event by using session.subscribe. This event supports both console API calls and Javascript errors.
| Reporter | ||
Comment 7•2 years ago
|
||
Thanks for the suggestions, Rob and Henrik. Can you point me to an example code that uses "log.entryAdded" and "session.subscribe" events to listen to console messages?
Comment 8•2 years ago
|
||
Well, that was just a pointer to where we have it implemented. But for a WebExtension API it won't make sense to directly use this code. Instead a proper API dedicated for WebExtension would have to be agreed on and implemented. Nevertheless can you find the related code from Webdriver BiDi here: https://searchfox.org/mozilla-central/source/remote/webdriver-bidi/modules/windowglobal/log.sys.mjs
| Reporter | ||
Comment 9•2 years ago
|
||
Thanks. Let me know if this feature will be implemented or any updates about using it from a web extension. Will keep waiting.
Comment 10•2 years ago
|
||
FYI: Greg has filed a bug to request access to the WebDriver BiDi protocol through an extension API at bug 1840132.
Comment 11•2 years ago
|
||
Not sure if it is actually a good idea to fallback to WebDriver BiDi's implementation here but better have a similar implementation for the WebExtensions API.
Description
•