Closed
Bug 445388
Opened 16 years ago
Closed 16 years ago
Incorrect error with XMLHttpRequest when loading chrome JS files
Categories
(Firefox :: General, defect)
Firefox
General
Tracking
()
RESOLVED
DUPLICATE
of bug 384298
People
(Reporter: christoph, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15 FirePHP/0.1.0.2 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15 FirePHP/0.1.0.2 I am loading from an extension a JS file contained within an extension via a XMLHttpRequest request and it is throwing a "not well-formed" error. When loading JS files from external domains no error is thrown. function handler() { if(this.readyState == 4 && this.status == 200) { Firebug.Console.log(this.responseText); } else if (this.readyState == 4 && this.status != 200) { Firebug.Console.log('oops error: '+this.status); Firebug.Console.log(this.responseText); } } var client = new XMLHttpRequest(); client.onreadystatechange = handler; client.open("GET", "chrome://firephp/content/FirePHP.js"); client.send(null); Reproducible: Always Steps to Reproduce: See code example in details. Actual Results: The request will execute, but return with a this.status = 0 and the this.responseText is set correctly to the content of the file. Expected Results: I don't think the "not well-formed" error should be thrown in this case and the status should be 200.
I think this is a duplicate of bug 331610. Either case, I think this is invalid because it's documented as returning 0 : http://developer.mozilla.org/en/docs/XMLHttpRequest#Example_with_non_http_protocol
Reporter | ||
Comment 2•16 years ago
|
||
The status = 0 is not the primary issue. The "not well-formed" error that gets thrown is the main problem.
I concur - mostly. The "not well formed" error being thrown is improper, and is different behavior from prior versions. This is not a dupe of 331610. The status code issue, however, has been explained, and the expected behavior is status = 0 for local files. I tested this with different local files, including some with valid XML. It appears that some type of XML integrity check is being done on the contents local files returned by XMLHttpRequest -- yet XMLHttpRequest is frequently used to retrieve local (chrome) non-XML files.
A little more digging turned up a related Bug 445388.
(In reply to comment #4) > A little more digging turned up a related Bug 445388. > Oops... should have been Bug 384298. I have a workaround using overrideMimeType method: req.open("GET", url, false); req.overrideMimeType('text/plain; charset=us-ascii'); req.send(null); This prevents the error from being thrown.... but it's only applicable since I am retrieving a local file that is part of the distribution in my extension, and I know its contents and can safely override the mime type.
Reporter | ||
Comment 6•16 years ago
|
||
Thanks for the workaround. This will work in my case. I guess we'll wait and see where #445388 ends up. Should this report be marked as a duplicate of #445388 ?
(In reply to comment #6) > > Should this report be marked as a duplicate of #445388 ? > Probably. I'm disappointed that even with the substantial prodding of the originator Carsten Orthbandt, no progress seems to have been made. I'd at least like someone to confirm it to New status.
Reporter | ||
Updated•16 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•