Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Backing out change 71efae8 for r=myk a=myk
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Mar 16, 2011
1 parent 36af513 commit 15ccf4d
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions packages/api-utils/lib/cuddlefish.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -239,7 +227,7 @@
fs: options.fs,
defaultPrincipal: "system",
globals: globals,
modifyModuleSandbox: createSandboxModifier(),
modifyModuleSandbox: modifyModuleSandbox,
securityPolicy: manifestChecker,
getModuleExports: getModuleExports};

Expand Down

0 comments on commit 15ccf4d

Please sign in to comment.