Closed
Bug 621276
Opened 14 years ago
Closed 12 years ago
Script tag onerror event does not fire if src attribute points to non-existing file://
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: st777, Unassigned)
References
Details
(Keywords: testcase)
Attachments
(1 file)
(deleted),
text/html
|
Details |
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
Comment 1•14 years ago
|
||
> 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
Comment 2•14 years ago
|
||
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.
Comment 3•14 years ago
|
||
> 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.
Comment 5•13 years ago
|
||
Updated•13 years ago
|
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
Comment 6•12 years ago
|
||
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
Comment 7•12 years ago
|
||
JFYI, according to Asqueella's testcase, WFM.
Comment 8•12 years ago
|
||
This got fixed in bug 789856, I would bet...
You need to log in
before you can comment on or make changes to this bug.
Description
•