From 15ccf4d150dab4786bd68d1b837f698a680e4775 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 16 Mar 2011 19:09:34 +0100 Subject: [PATCH] Backing out change 71efae8a660b63dcbf8e03635760fa18c0aa86b1 for r=myk a=myk --- packages/api-utils/lib/cuddlefish.js | 42 ++++++++++------------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/api-utils/lib/cuddlefish.js b/packages/api-utils/lib/cuddlefish.js index 834ff76fa..da99ca668 100644 --- a/packages/api-utils/lib/cuddlefish.js +++ b/packages/api-utils/lib/cuddlefish.js @@ -76,35 +76,17 @@ } var localFS = new securableModule.LocalFileSystem(myURI); + var es5path = localFS.resolveModule(null, "es5"); + var es5code = exports.es5code = localFS.getFile(es5path); - function createSandboxModifier() { - // If XULRunner version is >= 2.* then we have built-in implementation of - // ES5 additions. - var hasES5 = Cc["@mozilla.org/xre/app-info;1"]. - getService(Ci.nsIXULAppInfo).platformVersion[0] >= 2; - // In such case execution of "es5" module only slows down startup, there - // for we don't return `modifyModuleSandbox` function to avoid that. - if (hasES5) return; - - // If we got that far then we are on pre 2.* so we create a function that - // can be used to modify module sandboxes to add ES5 functionality. - var es5path = localFS.resolveModule(null, "es5"); - var es5code = exports.es5code = localFS.getFile(es5path); - es5code.filename = es5path; - - return function modifyModuleSandbox(sandbox, options) { - sandbox.evaluate(es5code); - var filename = options.filename ? options.filename : null; - sandbox.defineProperty("__url__", filename); - } - } + es5code.filename = es5path; function unloadLoader(reason) { this.require("unload").send(reason); } function maybeLoadMainInJetpackProcess(delegate, packaging) { - return function getModuleExports(basePath, module) { + return function getModuleExports(basePath, module) { if (module == packaging.options.main) { var mainURL = this.fs.resolveModule(basePath, module); var mainInfo = packaging.getModuleInfo(mainURL); @@ -144,6 +126,12 @@ }; } + function modifyModuleSandbox(sandbox, options) { + sandbox.evaluate(es5code); + var filename = options.filename ? options.filename : null; + sandbox.defineProperty("__url__", filename); + } + function makeManifestChecker(packaging) { var mc = { _allow: function _allow(loader, basePath, module, module_info) { @@ -152,7 +140,7 @@ } let mi = packaging.getModuleInfo(basePath); if (mi.needsChrome) - /* The module requires chrome, it can import whatever it + /* The module requires chrome, it can import whatever it * wants. */ return true; if (!mi.dependencies) { @@ -175,14 +163,14 @@ } else if (should_load != is_loading) { loader.console.warn("require(" + module + ") (called from " + basePath + ") is loading " + is_loading + - ", but is supposed to be loading " + + ", but is supposed to be loading " + should_load); //return false; // enable this in 0.9 } - return true; + return true; } } - loader.console.warn("undeclared require(" + module + + loader.console.warn("undeclared require(" + module + ") called from " + basePath); //return false; // enable this in 0.9 return true; @@ -239,7 +227,7 @@ fs: options.fs, defaultPrincipal: "system", globals: globals, - modifyModuleSandbox: createSandboxModifier(), + modifyModuleSandbox: modifyModuleSandbox, securityPolicy: manifestChecker, getModuleExports: getModuleExports};