Make sure rootDocument is set in Zotero.Translate.Web.setDocument()

For non-browser documents that we wrap, defaultView.top.document can be
undefined without being inaccessible.

Fixes regression from dae0986b9b
This commit is contained in:
Dan Stillman 2017-08-17 02:16:39 +02:00
parent 871cbae499
commit de36a6e833

View file

@ -1960,6 +1960,8 @@ Zotero.Translate.Web.prototype.setDocument = function(doc) {
this.rootDocument = doc.defaultView.top.document;
} catch (e) {
// Cross-origin frames won't be able to access top.document and will throw an error
}
if (!this.rootDocument) {
this.rootDocument = doc;
}
this.setLocation(doc.location.href, this.rootDocument.location.href);