From dae0986b9bec5a2e1008fa3b38fba8d0fe57551c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 15 Aug 2017 15:36:26 +0300 Subject: [PATCH] Fix a cross-origin frame access error in Translate.Web.setDocument --- chrome/content/zotero/xpcom/translation/translate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 31c39a516..11e051bab 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -1956,7 +1956,12 @@ Zotero.Translate.Web.prototype.Sandbox = Zotero.Translate.Sandbox._inheritFromBa */ Zotero.Translate.Web.prototype.setDocument = function(doc) { this.document = doc; - this.rootDocument = doc.defaultView.top.document || doc; + try { + this.rootDocument = doc.defaultView.top.document; + } catch (e) { + // Cross-origin frames won't be able to access top.document and will throw an error + this.rootDocument = doc; + } this.setLocation(doc.location.href, this.rootDocument.location.href); }