diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index a0b43450e6..fe4d3df658 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -242,10 +242,9 @@ Zotero.Translate.Sandbox = { }; safeTranslator.setDocument = function(arg) { if (Zotero.isFx && !Zotero.isBookmarklet) { - if (arg.wrappedJSObject && arg.wrappedJSObject.__wrappedObject) { - arg = arg.wrappedJSObject.__wrappedObject; - } - return translation.setDocument(new XPCNativeWrapper(arg)); + return translation.setDocument( + Zotero.Translate.DOMWrapper.wrap(arg, arg.__wrapperOverrides) + ); } else { return translation.setDocument(arg); } @@ -1774,11 +1773,15 @@ Zotero.Translate.Web.prototype._getSandboxLocation = function() { * Pass document and location to detect* and do* functions */ Zotero.Translate.Web.prototype._getParameters = function() { - if (Zotero.Translate.DOMWrapper && - Zotero.Translate.DOMWrapper.isWrapped(this.document) && - Zotero.platformMajorVersion >= 35) { - return [this._sandboxManager.wrap(Zotero.Translate.DOMWrapper.unwrap(this.document), null, - this.document.__wrapperOverrides), this.location]; + if (Zotero.Translate.DOMWrapper && Zotero.Translate.DOMWrapper.isWrapped(this.document)) { + return [ + this._sandboxManager.wrap( + Zotero.Translate.DOMWrapper.unwrap(this.document), + null, + this.document.__wrapperOverrides + ), + this.location + ]; } else { return [this.document, this.location]; } diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 9dec029337..293cff0a8d 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -222,7 +222,11 @@ Zotero.Translate.DOMWrapper = new function() { get(target, prop, receiver) { if (prop === "__wrappedObject") return this.wrappedObject; - + + if (prop == "__wrapperOverrides") { + return this.overrides; + } + if (prop in this.overrides) { return this.overrides[prop]; } @@ -256,11 +260,11 @@ Zotero.Translate.DOMWrapper = new function() { return { value: this.wrappedObject, writeable: true, configurable: true, enumerable: false }; } - if (name == "__wrapperOverrides") { + if (prop == "__wrapperOverrides") { return { value: this.overrides, writeable: false, configurable: false, enumerable: false }; } // Handle __exposedProps__. - if (name == "__exposedProps__") { + if (prop == "__exposedProps__") { return { value: ExposedPropsWaiver, writable: false, configurable: false, enumerable: false }; } @@ -426,6 +430,7 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) { }; wrappedRet.get = function(x, prop, receiver) { if (prop === "__wrappedObject") return target; + if (prop === "__wrapperOverrides") return overrides; if (prop === "__wrappingManager") return me; var y = overrides.hasOwnProperty(prop) ? overrides[prop] : target[prop]; if (y === null || (typeof y !== "object" && typeof y !== "function")) return y; @@ -607,8 +612,8 @@ Zotero.Translate.ChildSandboxManager.prototype = { "_makeContentForwarder":function(f) { return this._parent._makeContentForwarder(f); }, - "wrap":function(x) { - return this._parent.wrap(x); + "wrap": function (target, x, overrides) { + return this._parent.wrap(target, x, overrides); } }