Closed Bug 621276 Opened 9 years ago Closed 7 years ago

Script tag onerror event does not fire if src attribute points to non-existing file://

Categories

(Core :: DOM: Events, defect)

defect
Not set

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: st777, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

I'm attempting to inject a new script tag dynamically into a head element using DOM appendChild. When I inject a script tag that points to a non-existent file, onerror event of the injected script tag does not fire.

Reproducible: Always

Steps to Reproduce:
1. Create a new script tag: var newScript = document.createElement("script");
2. Bind an event to new script element: newScript.onerror = function() { alert('error!');}

3. Set src attribute of new script element to a bogus(non-existent) file: newScript.src = "foo.js";

4. Append new script element to head element: document.getElementsByTagName('head')[0].appendChild(newScript);
Actual Results:  
onError handler in step 2 does not fire

Expected Results:  
onError event must fire to let me know that something is wrong with loading a file

Test script is running locally on a desktop machine and not from a hosted location. Not sure if that makes a difference.

This behavior works correctly in all major browsers such as chrome, safari, IE 7-9
> Test script is running locally on a desktop machine and not from a hosted
> location. Not sure if that makes a difference.

It does.  For file:// URIs this is a known issue.

This is similar to bug 269125, and I was pretty sure we had a duplicate of this for <script> already...

Ms2ger, want to fix?
Whiteboard: DUPEME
Bug 608809?

Last time I looked at our script execution code (or the spec, for that matter), it looked sufficiently scary not to attempt a fix. I could try if you pointed me at the place I'd need to patch, though.
> Bug 608809?

That bug wfm.

> I could try if you pointed me at the place I'd need to patch, though.

We need to fire an error event if AsyncOpen on the script's channel returns failure.
Depends on: 282432
Duplicate of this bug: 646214
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
OS: Windows 7 → All
Hardware: x86_64 → All
Summary: Script tag onerror event does not fire if src attribute points to non-existing file → Script tag onerror event does not fire if src attribute points to non-existing file://
Whiteboard: DUPEME
Version: unspecified → Trunk
As more and more people are unit testing their JavaScript (and often using flat file:// URLs), this bug is pretty annoying.  There is some discussion of workarounds at Stack Overflow: http://stackoverflow.com/questions/4150430
JFYI, according to Asqueella's testcase, WFM.
This got fixed in bug 789856, I would bet...
Status: NEW → RESOLVED
Closed: 7 years ago
Depends on: 789856
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.