[webkit-dev] Passing null or undefined object as input url for XMLHttpRequest open()
ap at webkit.org
Tue Sep 4 08:32:41 PDT 2012
04.09.2012, в 07:43, Pozdnyakov, Mikhail написал(а):
> req = new XMLHttpRequest();
> req.open(“GET”, null);
> the implementation of XMLHttpRequest will try to open URL:
> “<base URL>/null“. The similar behaviour is with an undefined object given
> as input url (will try to open “<base URL>/undefined“).
> It does not seem to be correct behaviour and I would raise SYNTAX_ERR exception
> in such cases, but I would like to hear other opinions on that before creating bug and uploading patch.
This is an unlikely situation to occur in real web pages, so there is neither much risk nor much benefit to this change. One way this could break a page is if it calculates a URL and erroneously ends up with a null. In this case, raising an exception would further break page logic - instead of getting error and loaded events, it will likely be stuck waiting for these forever.
Could you elaborate on why this seems incorrect to you? Generally speaking, special casing just null and undefined to bypass toString conversion would be unusual and surprising.
- WBR, Alexey Proskuryakov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev