- Fix XMLHTTPRequest in Firefox 3.6

- Restore sending of cookies even if "Allow third-party cookies" is disabled (requires Firefox 3.6; not tested)
- Added Zotero.isFx36 for 1.9.2
This commit is contained in:
Dan Stillman 2009-10-31 07:26:15 +00:00
parent e15acb3e7e
commit 3959cf7fd0
2 changed files with 85 additions and 62 deletions

View file

@ -1012,16 +1012,9 @@ Zotero.Utilities.HTTP = new function() {
return false;
}
/*
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('GET', url, true);
*/
// Workaround for "Accept third-party cookies" being off in Firefox 3.0.1
// https://www.zotero.org/trac/ticket/1070
if (Zotero.isFx30) {
const Cc = Components.classes;
const Ci = Components.interfaces;
var ds = Cc["@mozilla.org/webshell;1"].
@ -1034,6 +1027,20 @@ Zotero.Utilities.HTTP = new function() {
xmlhttp.open("GET", url, true);
xmlhttp.channel.loadGroup = ds.getInterface(Ci.nsILoadGroup);
xmlhttp.channel.loadFlags |= Ci.nsIChannel.LOAD_DOCUMENT_URI;
}
else {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('GET', url, true);
// Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only)
if (!Zotero.isFx35) {
var channel = xmlhttp.channel;
channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
channel.forceAllowThirdPartyCookie = true;
}
}
/** @ignore */
xmlhttp.onreadystatechange = function() {
@ -1080,16 +1087,9 @@ Zotero.Utilities.HTTP = new function() {
return false;
}
/*
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('POST', url, true);
*/
// Workaround for "Accept third-party cookies" being off in Firefox 3.0.1
// https://www.zotero.org/trac/ticket/1070
if (Zotero.isFx30) {
const Cc = Components.classes;
const Ci = Components.interfaces;
var ds = Cc["@mozilla.org/webshell;1"].
@ -1102,6 +1102,20 @@ Zotero.Utilities.HTTP = new function() {
xmlhttp.open("POST", url, true);
xmlhttp.channel.loadGroup = ds.getInterface(Ci.nsILoadGroup);
xmlhttp.channel.loadFlags |= Ci.nsIChannel.LOAD_DOCUMENT_URI;
}
else {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('POST', url, true);
// Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only)
if (!Zotero.isFx35) {
var channel = xmlhttp.channel;
channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
channel.forceAllowThirdPartyCookie = true;
}
}
if (headers) {
if (typeof headers == 'string') {
@ -1162,16 +1176,9 @@ Zotero.Utilities.HTTP = new function() {
return false;
}
/*
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('HEAD', url, true);
*/
// Workaround for "Accept third-party cookies" being off in Firefox 3.0.1
// https://www.zotero.org/trac/ticket/1070
if (Zotero.isFx30) {
const Cc = Components.classes;
const Ci = Components.interfaces;
var ds = Cc["@mozilla.org/webshell;1"].
@ -1183,16 +1190,31 @@ Zotero.Utilities.HTTP = new function() {
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open("HEAD", url, true);
xmlhttp.channel.loadGroup = ds.getInterface(Ci.nsILoadGroup);
xmlhttp.channel.loadFlags |= Ci.nsIChannel.LOAD_DOCUMENT_URI;
}
else {
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('HEAD', url, true);
// Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only)
if (!Zotero.isFx35) {
var channel = xmlhttp.channel;
channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
channel.forceAllowThirdPartyCookie = true;
}
}
if (requestHeaders) {
for (var header in requestHeaders) {
xmlhttp.setRequestHeader(header, requestHeaders[header]);
}
}
xmlhttp.channel.loadGroup = ds.getInterface(Ci.nsILoadGroup);
xmlhttp.channel.loadFlags |= Ci.nsIChannel.LOAD_DOCUMENT_URI;
// Don't cache HEAD requests
xmlhttp.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
xmlhttp.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
/** @ignore */
xmlhttp.onreadystatechange = function(){

View file

@ -197,6 +197,7 @@ var Zotero = new function(){
|| appInfo.platformVersion.indexOf('1.9.0') === 0;
this.isFx35 = appInfo.platformVersion.indexOf('1.9.1') === 0;
this.isFx31 = this.isFx35;
this.isFx36 = appInfo.platformVersion.indexOf('1.9.2') === 0;
// OS platform
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]