commit 43fd51b71c8c9f09d86d731ff05e3a719ae14316
parent 1575ce9df01e6914411dc3a3de4cc37de4769e73
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 18 Oct 2010 21:35:50 +0000
fix CookieManager interaction with hidden browsers
Diffstat:
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/connector.js b/chrome/content/zotero/xpcom/connector.js
@@ -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 {
@@ -474,6 +479,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
+ */
"attachToXHR": function(xhr) {
this._watchedXHRs.push(xhr);
},
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -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;
}
/**