www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 11d9c1df041821dabe7d97cef73bde90abe2e8c3
parent 09e036e6faf9be0d535b0adb4fde1df446478f9d
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu, 22 Nov 2012 16:35:18 -0500

Fix issue reported by Aurimas at http://forums.zotero.org/discussion/25058/?Focus=140039#Comment_140039 (broken by https://bugzilla.mozilla.org/show_bug.cgi?id=761620)

Diffstat:
Mchrome/content/zotero/xpcom/cookieSandbox.js | 24++++++++++++++++++++----
Mchrome/content/zotero/xpcom/http.js | 6+++---
2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/chrome/content/zotero/xpcom/cookieSandbox.js b/chrome/content/zotero/xpcom/cookieSandbox.js @@ -102,7 +102,8 @@ Zotero.CookieSandbox.prototype = { * @param {nsIInterfaceRequestor} ir */ "attachToInterfaceRequestor": function(ir) { - Zotero.CookieSandbox.Observer.trackedInterfaceRequestors.set(ir.QueryInterface(Components.interfaces.nsIInterfaceRequestor), this); + Zotero.CookieSandbox.Observer.trackedInterfaceRequestors.push(Components.utils.getWeakReference(ir.QueryInterface(Components.interfaces.nsIInterfaceRequestor))); + Zotero.CookieSandbox.Observer.trackedInterfaceRequestorSandboxes.push(this); } } @@ -125,7 +126,8 @@ Zotero.CookieSandbox.Observer = new function() { */ this.register = function(CookieSandbox) { this.trackedBrowsers = new WeakMap(); - this.trackedInterfaceRequestors = new WeakMap(); + this.trackedInterfaceRequestors = []; + this.trackedInterfaceRequestorSandboxes = []; if(!observing) { Zotero.debug("CookieSandbox: Registering observers"); @@ -145,8 +147,22 @@ Zotero.CookieSandbox.Observer = new function() { // try the notification callbacks if(notificationCallbacks) { - trackedBy = this.trackedInterfaceRequestors.get(notificationCallbacks); - if(trackedBy) { + for(var i=0; i<this.trackedInterfaceRequestors.length; i++) { + // Interface requestors are stored as weak references, so we have to see + // if they still point to something + var ir = this.trackedInterfaceRequestors[i].get(); + if(!ir) { + // The interface requestor is gone, so remove it from the list + this.trackedInterfaceRequestors.splice(i--, 1); + this.trackedInterfaceRequestorSandboxes.splice(i--, 1); + } else if(ir == notificationCallbacks) { + // We are tracking this interface requestor + trackedBy = this.trackedInterfaceRequestorSandboxes[i]; + break; + } + } + + if(!trackedBy) { tested = true; } else { // try the browser diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js @@ -57,7 +57,7 @@ Zotero.HTTP = new function() { _stateChange(xmlhttp, onDone, responseCharset); }; - if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp); + if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp.getInterface(Components.interfaces.nsIInterfaceRequestor)); xmlhttp.send(null); return xmlhttp; @@ -142,7 +142,7 @@ Zotero.HTTP = new function() { _stateChange(xmlhttp, onDone, responseCharset); }; - if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp); + if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp.getInterface(Components.interfaces.nsIInterfaceRequestor)); xmlhttp.send(body); return xmlhttp; @@ -221,7 +221,7 @@ Zotero.HTTP = new function() { _stateChange(xmlhttp, onDone); }; - if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp); + if(cookieSandbox) cookieSandbox.attachToInterfaceRequestor(xmlhttp.getInterface(Components.interfaces.nsIInterfaceRequestor)); xmlhttp.send(null); return xmlhttp;