MozillaZine

HTTP Access Control in Camino

Talk about the native Mac OS X browser.

Moderator: Camino Developers

bsorin
 
Posts: 3
Joined: November 7th, 2009, 4:28 pm

Post Posted November 7th, 2009, 4:50 pm

Hi all!

I have a problem related to a javascript that uses XMLHttpRequest to get data from a file and insert it into the user page.

It goes like this:

I have a file (file A on domain1.tld) that contains a JS that accesses a remote file (file B on domain2.tld). The contents of File B are supposed to be inserted into file A whenever a user presses a button. The script didn't work (tested in Safari, FF 3.5, Camino) and I started looking into the problem. I found some information about the HTTP Access Control here.

File B is a PHP script so I added the following code to it:
Code: Select all
header("Access-Control-Allow-Origin: *");


After this the JS works on FF 3.5 and on Safari 4 but still doesn't in Camino and I figured it was due to the fact that Camino may not be able to check for the Access Control and just figures it's not supposed to use JS to insert content from another page. This is pure speculation on my part as I have not found any information regarding this.

Here is the JS lines I use to get the contents from file B:
Code: Select all
var file=new XMLHttpRequest();
file.open("GET", "http://www.bsorin.ro/~gmail/q.php", true);
file.onreadystatechange=function(){
     if (file.readyState===4){ text=file.responseText;}
};
file.send(null);
document.getElementById("x").innerHTML=text+document.getElementById("x").innerHTML;


Thanks to anyone who is willing to shed some light and help me find a solution for this.

phiw13
 
Posts: 2777
Joined: November 7th, 2002, 1:00 am
Location: Japan

Post Posted November 7th, 2009, 5:00 pm

This is all work done by Gecko (the rendering engine behind both Camino, Firefox).
Does your script work in Firefox 3.0 ? Camino 2.0 shares the same version of Gecko (1.9.0.x) with Firefox 3.0.x. Camino 1.6.x uses Gecko 1.8.1, shared with Firefox 2.0.x.

HTTP Access Control (Cors) was implemented in Gecko 1.9.1 (Firefox 3.5).

bsorin
 
Posts: 3
Joined: November 7th, 2009, 4:28 pm

Post Posted November 7th, 2009, 5:30 pm

Camino 2.0b4 and it doesn't work and neither does FF 2.0.0.20.

I don't know what to make of this.

cflawson

User avatar
 
Posts: 4721
Joined: December 26th, 2004, 2:54 pm
Location: Flying over your house in a red, white, and blue jet

Post Posted November 7th, 2009, 8:02 pm

Yeah, I'm pretty sure cross-site XHR doesn't work in Gecko 1.9.0 or earlier. Someone should double-check that in Bugzilla, but I'm pretty sure I saw a bug for that and it isn't getting fixed on anything older than whatever Gecko branch Firefox 3.5 came from. (1.9.1, I think.)

cl

phiw13
 
Posts: 2777
Joined: November 7th, 2002, 1:00 am
Location: Japan

Post Posted November 7th, 2009, 8:23 pm

cflawson wrote:Yeah, I'm pretty sure cross-site XHR doesn't work in Gecko 1.9.0 or earlier. Someone should double-check that in Bugzilla, but I'm pretty sure I saw a bug for that and it isn't getting fixed on anything older than whatever Gecko branch Firefox 3.5 came from. (1.9.1, I think.)

bug 389508, implemented in Gecko 1.9.1 as I said.

bsorin
 
Posts: 3
Joined: November 7th, 2009, 4:28 pm

Post Posted November 8th, 2009, 1:45 pm

Thanks!

So I guess there is no way to get a workaround for this in Camino until it runs on Geko 1.9.1, is there?

hendy
 
Posts: 62
Joined: March 23rd, 2005, 3:05 am

Post Posted November 8th, 2009, 7:49 pm

You might be able to use JSONP.

Return to Camino


Who is online

Users browsing this forum: No registered users and 1 guest