(This was split off from bug 4403). Script elements should generate a load event when they're finished loading. Question: should this apply only to dynamically-loaded scripts?
I'm not sure about other elements, but I thing the onload event should be fired for every kind of resource that is loaded from outside the page (scripts, css, images, embedded, etc...) For scripts, on bug 4403, it was proposed to add a simple "dispatchHTMLEvent (loadEvent, false, false);" as the last call at "HTMLScriptElementImpl::notifyFinished" to fix this problem. Would it be the right way? Also, an important thing to note... the "onload" event (for scripts) must be fired when the script file has been loaded (even from the cache) AND evaluated, so it is really available to be used. And if the file is not found, the "onerror" should be fired instead. Is that right?
(In reply to comment #1) > For scripts, on bug 4403, it was proposed to add a simple "dispatchHTMLEvent > (loadEvent, false, false);" as the last call > at "HTMLScriptElementImpl::notifyFinished" to fix this problem. Would it be the > right way? That change was incomplete (not pertaining to script elements created by the parser) and incorrect (the load event was emitted even when an prevented loading or parsing, instead of the error event, which may explain the behavior you reported in the comment on the other bug).
Created attachment 5123 [details] minimalistic patch I haven't tested this thoroughly yet, but I'm posting it in case FredCK or others would like to give it a try.
Created attachment 5237 [details] Dispatch load and error events for script elements
Created attachment 5238 [details] Dispatch load and error events for script elements
This patch looks good to me, but I'd like someone with more experience in this code to take a look. FYI, Safari doesn't seem to know what to do with the linked patch, so you have to hit "view source" to see it. What happens with a script source of ""? Does that just generate a load error?
(In reply to comment #6) > FYI, Safari doesn't seem to know what to do with the linked patch, so you have to hit "view source" to see > it. Hmm... I can't reproduce this in TOT. > What happens with a script source of ""? Does that just generate a load error? Not sure what you mean by a "load error". It generates a load event. Firefox behaves the same.
Created attachment 5252 [details] Dispatch load and error events for script elements Oops, shouldn't have let the node get deleted during script execution.
Comment on attachment 5252 [details] Dispatch load and error events for script elements This looks great. r=me
*** Bug 6640 has been marked as a duplicate of this bug. ***