fix CookieManager interaction with hidden browsers
This commit is contained in:
parent
1575ce9df0
commit
43fd51b71c
|
@ -349,6 +349,7 @@ Zotero.Connector.DataListener.prototype._requestFinished = function(response) {
|
|||
Zotero.Connector.CookieManager = function(browser, uri, cookieData) {
|
||||
this._webNav = browser.webNavigation;
|
||||
this._browser = browser;
|
||||
this._watchedBrowsers = [browser];
|
||||
this._observerService = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
|
||||
|
@ -381,7 +382,11 @@ Zotero.Connector.CookieManager.prototype = {
|
|||
channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
var isTracked = null;
|
||||
try {
|
||||
isTracked = channel.notificationCallbacks.getInterface(Components.interfaces.nsIDOMWindow).top.document == this._browser.contentDocument;
|
||||
var topDoc = channel.notificationCallbacks.getInterface(Components.interfaces.nsIDOMWindow).top.document;
|
||||
for each(var browser in this._watchedBrowsers) {
|
||||
isTracked = topDoc == browser.contentDocument;
|
||||
if(isTracked) break;
|
||||
}
|
||||
} catch(e) {}
|
||||
if(isTracked === null) {
|
||||
try {
|
||||
|
@ -470,6 +475,14 @@ Zotero.Connector.CookieManager.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach CookieManager to a specific XMLHttpRequest
|
||||
* @param {XMLHttpRequest} xhr
|
||||
*/
|
||||
"attachToBrowser": function(browser) {
|
||||
this._watchedBrowsers.push(browser);
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach CookieManager to a specific XMLHttpRequest
|
||||
* @param {XMLHttpRequest} xhr
|
||||
|
|
|
@ -856,7 +856,8 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor
|
|||
}
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.processDocuments(urls, processor, done, exception);
|
||||
var hiddenBrowser = Zotero.Utilities.HTTP.processDocuments(urls, processor, done, exception);
|
||||
if(this.translate.cookieManager) this.translate.cookieManager.attachToBrowser(hiddenBrowser);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -876,6 +877,7 @@ Zotero.Utilities.Translate.prototype.retrieveDocument = function(url) {
|
|||
}
|
||||
|
||||
var hiddenBrowser = Zotero.Browser.createHiddenBrowser();
|
||||
if(this.translate.cookieManager) this.translate.cookieManager.attachToBrowser(hiddenBrowser);
|
||||
hiddenBrowser.addEventListener("pageshow", listener, true);
|
||||
hiddenBrowser.loadURI(url);
|
||||
|
||||
|
@ -1588,6 +1590,7 @@ Zotero.Utilities.HTTP = new function() {
|
|||
hiddenBrowser.addEventListener(loadEvent, onLoad, true);
|
||||
|
||||
doLoad();
|
||||
return hiddenBrowser;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user