commit ab96c38037fba6b9ad787427920f937358e87da7
parent d89dcd3b87e20562e7c479dfd8a306738691e1d1
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 7 Feb 2011 08:26:06 +0000
fix for fx 3.6
Diffstat:
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/browser_firefox.js b/chrome/content/zotero/xpcom/translation/browser_firefox.js
@@ -46,18 +46,22 @@ Zotero.Translate.SandboxManager = function(translate, sandboxLocation) {
// import functions missing from global scope into Fx sandbox
this.sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
this.sandbox.DOMParser = function() {
- // get principal
- if(typeof sandboxLocation !== "string") { // if sandbox specified by DOM document
- var principal = sandboxLocation.nodePrincipal;
- } else { // if sandbox specified by URI
- var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
- .getService(Components.interfaces.nsIScriptSecurityManager);
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var uri = ioService.newURI(sandboxLocation, "UTF-8", null);
- var principal = secMan.getCodebasePrincipal(uri);
+ // 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 principal from URI
+ var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
+ .getService(Components.interfaces.nsIScriptSecurityManager);
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ uri = ioService.newURI(uri, "UTF-8", null);
+ var principal = secMan.getCodebasePrincipal(uri);
+
// initialize DOM parser
var _DOMParser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);