Closed Bug 789856 Opened 7 years ago Closed 7 years ago

script errors not handled when script blocked by a Content Policy

Categories

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

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla18

People

(Reporter: tanvi, Assigned: bzbarsky)

References

Details

Attachments

(1 file, 3 obsolete files)

When a Content Policy blocks a script, the error from the script is not handled with an error event that propogates to the client (and is hence displayed to the developer in the Error Console or Web Console).

I discovered this while trying to catch a script load error with the onerror event when a the mixed content Content Policy blocked the script.

I believe the error should be handled in CheckContentPolicy in nsScriptLoader.cpp:
mxr.mozilla.org/mozilla-central/source/content/base/src/nsScriptLoader.cpp#212
So this is basically about us firing onerror on the script if the script is blocked by CheckLoadURI or content policy?

Jonas, any objections?  In particular, would this let sites detect when ad-blockers are in use in ways they can't right now?
(In reply to Boris Zbarsky (:bz) from comment #1)
> Jonas, any objections?  In particular, would this let sites detect when
> ad-blockers are in use in ways they can't right now?

I doubt that's possible: it's trivial to add a side-effect to a script and check whether that side-effect happened in a later script in the page.
I agree. It will always be possible to detect that a script is blocked, so being explicit about it seems ok.
Assignee: nobody → bzbarsky
Whiteboard: [need review]
Comment on attachment 661587 [details] [diff] [review]
Fire error events on <script> elements which completely fail to start the load.

>+		test_bug789856.html \

This file is missing.
Attached patch Now with the test file (obsolete) — Splinter Review
Good catch!
Attachment #661590 - Flags: review?(jonas)
Attachment #661587 - Attachment is obsolete: true
Attachment #661587 - Flags: review?(jonas)
Attachment #662316 - Flags: review?(jonas)
Attachment #661590 - Attachment is obsolete: true
Attachment #662316 - Attachment is obsolete: true
Attachment #662316 - Flags: review?(jonas)
https://hg.mozilla.org/mozilla-central/rev/e61b7c193325
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Blocks: 621276
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.