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])
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 Steps to reproduce: Support to listen console messages using new browser extensions. i.e. https://developer.mozilla.org/en-US/docs/Tools/Browser_Console Actual results: No support as of now. Expected results: Way to access console messages through extensions.
Updated•7 years ago
|
Comment 1•7 years ago
|
||
It helps streamline the decision-making progress for proposed new APIs if you can explain what sorts of extensions would use this API and how they would use it.
Updated•7 years ago
|
Reporter | ||
Comment 2•7 years ago
|
||
We are using the consoleexport (https://github.com/firebug/consoleexport) extension to download all console log messages for our QA automation testing purposes. ConsoleExport actually uses Firebug to listen console logs. When Firebug is deprecated by Firefox, we moved to this example (https://github.com/firebug/devtools-extension-examples/tree/master/ConsoleListener) posted in GitHub to achieve the same. The example used the console API as i mentioned in the bug description but that's gone now in Firefox Quantum. Can you please add console API support in new web-extensions framework?
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•2 years ago
|
Comment 3•1 year 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•1 year 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•1 year 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.console
with 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•1 year 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•1 year 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•1 year 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•1 year 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•1 year ago
|
||
FYI: Greg has filed a bug to request access to the WebDriver BiDi protocol through an extension API at bug 1840132.
Comment 11•1 year 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
•