From 009e315fa18fbf2120a6fb8ececeaca20baa2a3a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 2 Aug 2012 20:25:41 -0400 Subject: [PATCH] Fix compatibility with latest Nightly --- .../xpcom/translation/translate_firefox.js | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index f96d07d9c5..62437cc48e 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -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 * @param {Zotero.Translate} translate @@ -369,27 +376,16 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) { ? sandboxLocation.wrappedJSObject.DOMParser : sandboxLocation.DOMParser; } else { this.sandbox.DOMParser = function() { + var uri, principal; // get URI // 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 - 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 - var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Components.interfaces.nsIScriptSecurityManager); - var principal = secMan.getCodebasePrincipal(uri); + var secMan = Services.scriptSecurityManager; + principal = (secMan.getCodebasePrincipal || secMan.getSimpleCodebasePrincipal) + (Services.io.newURI(sandboxLocation, "UTF-8", null)); + } else { // if sandbox specified by DOM document + uri = sandboxLocation.document.nodePrincipal; } // initialize DOM parser