Open Bug 1215171 Opened 9 years ago Updated 2 years ago

Ability to listen for javascript warnings, similar to window.onerror event handler

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: sworddragon2, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0
Build ID: 20151003161951

Steps to reproduce:

I wanted to listen for javascript errors and have noticed that window.onerror doesn't trigger on javascript warnings.



Expected results:

Javascript warnings should also trigger window.onerror or there could maybe be another way to listen for them.
Severity: normal → enhancement
An example of code with that problem?
What for code do you expect me to upload? A proof that this feature does not exist? Or did you just mean a use-case for this feature?
Use-case is useful to create a test for check that problem :-)
Yes, an HTML testcase that works in another browser and not Firefox can be a very useful thing :)
The problem I wanted to point to is that a testcase may be currently only semi-useful as for the current state of this report it is unknown if window.onerror should catch warnings or not. So either this is a bug and I could upload a testcase that tries to catch a warning and does fail at this point or this behavior is wanted and this is a feature request as it looks weird to me that we can catch any verbose behavior from console.* output over modal dialogs up to javascript errors but not javascript warnings.
Sounds like a feature request. What types of warnings were you specifically interested in and why?
Component: Untriaged → DOM
Product: Firefox → Core
Summary: Ability to listen for javascript warnings → Ability to listen for javascript warnings, similar to window.onerror event handler
Version: 41 Branch → Trunk
I'm interested in catching all warnings that do not trigger window.onerror. The reason is simple: To suppress warnings from code which I don't control. More precisely I'm loading untrusted content in an iframe and using a sandbox with allow-scripts since I need the content to evaluate its initial state. But allow-scripts is too permissive for me in this case as the content should never be able to make any potential verbose actions. Because of this I'm also manually restricting the sandbox a bit more:

- By disabling modal dialogs (window.alert(), window.confirm() and window.prompt()).
- By disabling all functions in console.
- By assigning its window.parent its window.
- By suppressing JavaScript errors.

Only JavaScript warnings are missing (like ones from javascript.options.strict) and they can mix up with warnings from my code which makes them more difficult to notice in the console.
I personally don't think we should be adding more complexity to support javascript.options.strict, especially if this would be web-visible complexity for what is fundamentally not a web-facing feature.
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.