RESOLVED FIXED 5812
Generate load events for <script> elements
https://bugs.webkit.org/show_bug.cgi?id=5812
Summary Generate load events for <script> elements
mitz
Reported 2005-11-23 11:30:49 PST
(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?
Attachments
minimalistic patch (11.52 KB, patch)
2005-12-17 13:16 PST, mitz
no flags
Dispatch load and error events for script elements (11.52 KB, patch)
2005-12-23 01:35 PST, mitz
no flags
Dispatch load and error events for script elements (17.96 KB, patch)
2005-12-23 01:36 PST, mitz
no flags
Dispatch load and error events for script elements (17.96 KB, patch)
2005-12-23 13:16 PST, mitz
darin: review+
webkit
Comment 1 2005-11-29 08:15:02 PST
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?
mitz
Comment 2 2005-11-29 12:13:59 PST
(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).
mitz
Comment 3 2005-12-17 13:16:19 PST
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.
mitz
Comment 4 2005-12-23 01:35:23 PST
Created attachment 5237 [details] Dispatch load and error events for script elements
mitz
Comment 5 2005-12-23 01:36:14 PST
Created attachment 5238 [details] Dispatch load and error events for script elements
Geoffrey Garen
Comment 6 2005-12-23 10:47:28 PST
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?
mitz
Comment 7 2005-12-23 11:22:17 PST
(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.
mitz
Comment 8 2005-12-23 13:16:50 PST
Created attachment 5252 [details] Dispatch load and error events for script elements Oops, shouldn't have let the node get deleted during script execution.
Darin Adler
Comment 9 2005-12-25 08:00:18 PST
Comment on attachment 5252 [details] Dispatch load and error events for script elements This looks great. r=me
Mark Rowe (bdash)
Comment 10 2006-01-17 22:02:13 PST
*** Bug 6640 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.