From 1e1ec2e92ce2ef2d11d93b46875f38b57e452024 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 7 May 2015 19:31:27 -0400 Subject: [PATCH] Firefox: this fixes ocasional bad cookie handling --- platform/firefox/vapi-background.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index a542f73..3aba4e7 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1930,11 +1930,14 @@ vAPI.cookies.observe = function(subject, topic, reason) { if ( topic !== 'cookie-changed' ) { return; } - var handler = reason === 'deleted' ? this.onRemoved : this.onChanged; - if ( typeof handler !== 'function' ) { + // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICookieService + if ( reason === 'deleted' || subject instanceof Ci.nsICookie2 === false ) { return; } - handler(new this.CookieEntry(subject.QueryInterface(Ci.nsICookie))); + if ( typeof this.onChanged !== 'function' ) { + return; + } + this.onChanged(new this.CookieEntry(subject)); }; /******************************************************************************/