[Webkit-unassigned] [Bug 16716] XHR Handler may call undefined function

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 3 04:59:46 PST 2008


http://bugs.webkit.org/show_bug.cgi?id=16716


mjs at apple.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #6 from mjs at apple.com  2008-01-03 04:59 PDT -------
I think this bug is invalid. Reasons to believe the current behavior is not
wrong:

1) Other browsers have the same behavior (making it highly unlikely this fix is
required for web compatibility).
2) The XHR spec does not require anything to the contrary.
3) Synchronous XHR has the same behavior.
4) It's easy for authors to ensure an async XHR doesn't call an undefined
function from its onreadystatechange handler, there are at least two very easy
ways. 
    a) ensure that all functions you need are defined in the same script or
earlier scripts as the one where you start the XHR - this works because
<script> processing blocks the parser and is serialized.
    b) start your XHR from the document's "load" event or DOMContentLoaded
event.
5) <img onload=""> can similarly fire before the document's "load" event;
indeed, in this case it is required that the image's load event fire before the
document's!

All of these arguments seriously undermine the claim that the current WebKit
behavior is wrong.

Furthermore, delaying async XHR replies may be harmful to site loading
performance. Many sites use "AJAX" techniques as part of the page load process
but may also contain individual slow-loading resources, such as ads. Making
this fix could cause display of useful site content to be delayed waiting for
ads, in a way that can't happen in other browsers.

I suspect Adobe made this change because they created some buggy HTML/JS
content as an AIR demo and mistakenly thought the bug was in WebKit rather than
their code. I'm thinking something like this:

<script>
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = handler;
xhr.open("GET", "something.xml");
xhr.send();
function handler() {
    someLibraryFunction();
}
</script>
<script src="external-lib.js"></script>

But that code is incorrect as written - the order of the two <script> elements
should be reversed.

Therefore, closing this bug as INVALID unless there's a further argument as to
why this behavior is wrong.


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list