Fix compatibility with latest Nightly
This commit is contained in:
parent
77f422039f
commit
009e315fa1
1 changed files with 13 additions and 17 deletions
|
@ -350,6 +350,13 @@ Zotero.Translate.DOMWrapper = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Manages the translator sandbox
|
||||||
|
* @param {Zotero.Translate} translate
|
||||||
|
* @param {String|window} sandboxLocation
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Manages the translator sandbox
|
* @class Manages the translator sandbox
|
||||||
* @param {Zotero.Translate} translate
|
* @param {Zotero.Translate} translate
|
||||||
|
@ -369,27 +376,16 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) {
|
||||||
? sandboxLocation.wrappedJSObject.DOMParser : sandboxLocation.DOMParser;
|
? sandboxLocation.wrappedJSObject.DOMParser : sandboxLocation.DOMParser;
|
||||||
} else {
|
} else {
|
||||||
this.sandbox.DOMParser = function() {
|
this.sandbox.DOMParser = function() {
|
||||||
|
var uri, principal;
|
||||||
// get URI
|
// get URI
|
||||||
// DEBUG: In Fx 4 we can just use document.nodePrincipal, but in Fx 3.6 this doesn't work
|
// DEBUG: In Fx 4 we can just use document.nodePrincipal, but in Fx 3.6 this doesn't work
|
||||||
if(typeof sandboxLocation === "string") { // if sandbox specified by URI
|
if(typeof sandboxLocation === "string") { // if sandbox specified by URI
|
||||||
var uri = sandboxLocation;
|
|
||||||
} else { // if sandbox specified by DOM document
|
|
||||||
var uri = sandboxLocation.location.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get from nsIURI
|
|
||||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
uri = ioService.newURI(uri, "UTF-8", null);
|
|
||||||
|
|
||||||
if(typeof sandboxLocation === "object" && sandboxLocation.nodePrincipal) {
|
|
||||||
// if sandbox specified by DOM document, use nodePrincipal property
|
|
||||||
var principal = sandboxLocation.nodePrincipal;
|
|
||||||
} else {
|
|
||||||
// if sandbox specified by URI, get codebase principal from security manager
|
// if sandbox specified by URI, get codebase principal from security manager
|
||||||
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
var secMan = Services.scriptSecurityManager;
|
||||||
.getService(Components.interfaces.nsIScriptSecurityManager);
|
principal = (secMan.getCodebasePrincipal || secMan.getSimpleCodebasePrincipal)
|
||||||
var principal = secMan.getCodebasePrincipal(uri);
|
(Services.io.newURI(sandboxLocation, "UTF-8", null));
|
||||||
|
} else { // if sandbox specified by DOM document
|
||||||
|
uri = sandboxLocation.document.nodePrincipal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize DOM parser
|
// initialize DOM parser
|
||||||
|
|
Loading…
Reference in a new issue