NEW 12307
No way to test error condition of synchronous XMLHttpRequest to file:///
https://bugs.webkit.org/show_bug.cgi?id=12307
Summary No way to test error condition of synchronous XMLHttpRequest to file:///
Jesse Costello-Good
Reported 2007-01-17 17:40:10 PST
There is no way to tell whether an asynchronous XML HTTP request to the local disk (when running a page from file:///) has failed. // #1 works ok from HTTP var r = new XMLHttpRequest(); r.open("GET", "http://www.apple.com/nowhere.html", true); r.send(); // wait ... r.status == 404 // #2 works ok synchronously var r = new XMLHttpRequest(); r.open("GET", "nowhere.html", false); r.send(); // throws an error  // #3 but asynchronously ... no way to detect the error var r = new XMLHttpRequest(); r.open("GET", "nowhere.html", true); r.send(); // wait ... no error thrown r.status == 0 Both Internet Explorer and Firefox seem to ignore async when requesting a resource from the local disk. They both throw an exception like Safari does in the second example. But they also both throw an exception in the third example whereas Safari doesn't.
Attachments
test case (1.21 KB, text/html)
2007-02-15 02:55 PST, Alexey Proskuryakov
no flags
WIP patch (7.03 KB, patch)
2014-06-13 15:56 PDT, Alexey Proskuryakov
no flags
slightly better, but still fails tests (9.46 KB, patch)
2014-06-13 17:04 PDT, Alexey Proskuryakov
no flags
Alexey Proskuryakov
Comment 1 2007-02-15 02:55:43 PST
Created attachment 13181 [details] test case In the future, we will probably dispatch an error event for XMLHttpRequest. From my testing, it appears that IE 7 refuses to load local files altogether. Firefox 2 does raise an exception in send(), but if a local file is accessible, then the actual loading happens asynchronously. This behavior is not in accordance with draft XMLHttpRequest spec AFAICT.
Julien Chaffraix
Comment 2 2008-08-23 03:36:12 PDT
(In reply to comment #1) > Created an attachment (id=13181) [edit] > test case > > In the future, we will probably dispatch an error event for XMLHttpRequest. We have implemented 'onerror' from XMLHttpRequest level 2, which means that we now have a way to check for asynchronous request failures. However during my quick testing, I have tried doing a synchronous one to a non-existent file (just modify the given test case to do a synchronous request) and we do not dispatch an error event nor do we throw an exception. We do not raise an exception because it breaks some website (see http://trac.webkit.org/changeset/23889) but we could at least dispatch an event so there is a way to determine that an error occurred.
Alexey Proskuryakov
Comment 3 2009-02-24 07:25:32 PST
Renaming the bug, as it now tracks sync requests, not async ones.
Marcus Better
Comment 4 2009-09-22 07:07:25 PDT
(In reply to comment #1) > From my testing, it appears that IE 7 refuses to load local files > altogether. This is not quite accurate, it can load local files if the native XHR implementation is switched on in the "Advanced" tab of the "Internet Options".
Alexey Proskuryakov
Comment 5 2014-06-13 15:56:51 PDT
Created attachment 233084 [details] WIP patch Fails some tests.
Alexey Proskuryakov
Comment 6 2014-06-13 17:04:44 PDT
Created attachment 233094 [details] slightly better, but still fails tests
Note You need to log in before you can comment on or make changes to this bug.