Opened 9 years ago

Closed 7 years ago

#11365 closed defect (wontfix)

'not wellformed' warning from firefox when working on locale files

Reported by: Heiko Kendziorra Owned by: James Burke
Priority: high Milestone: future
Component: Loader Version: 1.4.3
Keywords: firefox local file well formed Cc:
Blocked By: Blocking:

Description

Hi, my application has to work remote over http and from the local file system. Because of it is not sure, that internet is available the whole dojo libary is on the local file system.

Using Firefox and starting my application dojo trys to load the requestet *.js files (because of dojo.required....). For each requested file firefox error console throws a 'not wellformed' warning. The reason seems to be, that the locale filesystem not creates a http response header to inform Firefox about the mimetype - and so Firefox 'thinks' to get a xml document and trys to parse it. But it isn't xml and so the warning comes.

A similarly problem I got on loading data for a csv-store - with a local file. Here I got a 'syntax error' in the firefox error console. It seem to be the same problem.

For my self I made a hotfix in dojo/_base/xhr.js:

...
xhr.open(method, ioArgs.url, args.sync !== true, args.user || undefined, args.password || undefined);

if(args.headers){
   for(var hdr in args.headers){
      if(hdr.toLowerCase() === "content-type" && !args.contentType){
         args.contentType = args.headers[hdr];
      }else if(args.headers[hdr]){
         //Only add header if it has a value. This allows for instnace, skipping
         //insertion of X-Requested-With by specifying empty value.
         xhr.setRequestHeader(hdr, args.headers[hdr]);
      }
   }
}
/*begin hotfix*/
if(d.isMoz){
   xhr.overrideMimeType("text/plain");
} 
/*end hot fix*/  

similarly I fixed for my self hostenv_browser.js

...
d._getText = function(/*URI*/ uri, /*Boolean*/ fail_ok){
// summary: Read the contents of the specified uri and return those contents.
// uri: ...
var http = d._xhrObj();

/*begin hot fix*/     
if(d.isMoz){
   http.overrideMimeType("text/plain");
}
/*end hot fix*/  

Completely the query 'if(d.isMoz)' is to hard and there is needed to ask for isLocaleRequest or similar. But I dont know how to ask this.

This is to do.

best regards Heiko Kendziorra (DResearch/Berlin)

Change History (4)

comment:1 Changed 9 years ago by James Burke

Milestone: tbdfuture
Owner: changed from anonymous to James Burke

Working off the file system has a few issues across browsers. I am not sure it makes sense to try to support this unless we say we try to support file system access in general, which is hard to do particularly since Firefox requires the user to change a hidden pref to do it. Chrome has local file restrictions, and IIRC, they cannot be turned off.

So do you only need to support Firefox or more than just Firefox? How do you expect users to use it in Firefox if they have to change a hidden preference?

comment:2 Changed 9 years ago by Heiko Kendziorra

At this moment I dont want to support a file system in general by dojo.

But how is the situation? Javascript application become more comfortable and faster using frameworks like dojo. All over the last 20 years exist local file system websites e.g. for help systems. All browser support links to local textfiles (in a subfolder structure to the calling site). Now I try to use it asyncron but unfortunately there is a 'X' in 'AJAX' for xml. But the times are gone where only xml is transported by a XMLHTTP-Request. For this fact the Mozilla engine supports on its interface the overrideMimeType method. We should use it, when we dont know what mimetype we expect.

No where is written, that dojo only works with internet support or from a webserver. We should document the error messages from firefox (faq?) or fix it. It cost me a lot of time to realize, that it was not my error what I saw and to found the reason. Other developers should not have to do the same.

comment:3 Changed 9 years ago by David Rees

+1, at least for a better error message. This took me a while to figure out also.

comment:4 Changed 7 years ago by bill

Component: CoreLoader
Resolution: wontfix
Status: newclosed

Yah, I agree with James, I don't think we can support loading through file://.

Regarding the error message, I think it's fairly clear:

Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "file:///workspace/trunk/dojo/_base/xhr.js Line: 736"]
error = new Error(error); 

Could be a little clearer, but that's more of an issue for firefox than for dojo.

Note: See TracTickets for help on using tickets.