mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:37:58 +01:00
Use sandboxes for all JS contexts, to fix breakage, now that we have CPG anyway.
--HG-- extra : rebase_source : 0eb9d8c6a8ee533d6e12d71372554163f9479cf2
This commit is contained in:
@@ -484,7 +484,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (fileName && fileName[0] == "[")
|
||||
fileName = "dactyl://command-line/";
|
||||
else if (!context)
|
||||
context = ctxt || _userContext;
|
||||
context = ctxt || userContext;
|
||||
|
||||
if (isinstance(context, ["Sandbox"]))
|
||||
return Cu.evalInSandbox(str, context, "1.8", fileName, lineNumber);
|
||||
|
||||
@@ -138,8 +138,8 @@ var Contexts = Module("contexts", {
|
||||
completer: function (context) modules.completion.group(context)
|
||||
});
|
||||
|
||||
memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, true]));
|
||||
memoize(modules, "_userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules.userContext]));
|
||||
memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, false]));
|
||||
memoize(modules, "_userContext", () => modules.userContext);
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
|
||||
@@ -55,7 +55,7 @@ var JavaScript = Module("javascript", {
|
||||
|
||||
lazyInit: true,
|
||||
|
||||
newContext: function () this.modules.newContext(this.modules.userContext, true, "Dactyl JS Temp Context"),
|
||||
newContext: function () this.modules.newContext(this.modules.userContext, false, "Dactyl JS Temp Context"),
|
||||
|
||||
completers: Class.Memoize(() => Object.create(JavaScript.completers)),
|
||||
|
||||
|
||||
@@ -132,17 +132,15 @@ var Modules = function Modules(window) {
|
||||
if (normal)
|
||||
return create(proto);
|
||||
|
||||
if (services.has("dactyl") && services.dactyl.createGlobal)
|
||||
var sandbox = services.dactyl.createGlobal();
|
||||
else
|
||||
sandbox = Components.utils.Sandbox(window, { sandboxPrototype: proto || modules,
|
||||
sandboxName: name || ("Dactyl Sandbox " + ++_id),
|
||||
wantXrays: false });
|
||||
sandbox = Components.utils.Sandbox(window, { sandboxPrototype: proto || modules,
|
||||
sandboxName: name || ("Dactyl Sandbox " + ++_id),
|
||||
wantXrays: false });
|
||||
|
||||
// Hack:
|
||||
// sandbox.Object = jsmodules.Object;
|
||||
sandbox.File = jsmodules.File;
|
||||
sandbox.Math = jsmodules.Math;
|
||||
sandbox.Set = jsmodules.Set;
|
||||
sandbox.__proto__ = proto || modules;
|
||||
return sandbox;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user