2012-07-28 23:00:27 +02:00
|
|
|
[eval]
|
|
|
|
[eval]:1
|
|
|
|
with(this){__filename}
|
|
|
|
^^^^
|
|
|
|
SyntaxError: Strict mode code may not include a with statement
|
vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.
Functionally, this fixes #3042. In particular:
- A context is now indistinguishable from the object it is based on
(the "sandbox"). A context is simply a sandbox that has been marked
by the vm module, via `vm.createContext`, with special internal
information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
immediately visible to all code that can access that context, both
inside and outside the virtual machine.
This commit also smooths over the API very slightly:
- Parameter defaults are now uniformly triggered via `undefined`, per
ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
the conflation of `vm.Script` with `vm` itself, and the fact that
`Script` instances also had all static `vm` methods. The API is now
exactly as documented (although arguably the existence of the
`vm.Script` export is not yet documented, just the `Script` class
itself).
In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.
The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:
- ContextifyScript(code, [filename]), with methods:
- runInThisContext()
- runInContext(sandbox, [timeout])
- makeContext(sandbox)
From this, the vm.js file builds the entire documented vm module API.
node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.
The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.
New tests were also added, of course, demonstrating the new
capabilities and fixes.
[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-07-27 06:34:12 +02:00
|
|
|
at Object.exports.runInThisContext (vm.js:*)
|
2012-08-05 20:26:18 +02:00
|
|
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
|
|
|
at Module._compile (module.js:*:*)
|
2016-09-28 12:01:48 +02:00
|
|
|
at Immediate.<anonymous> (bootstrap_node.js:*:*)
|
|
|
|
at runCallback (timers.js:*:*)
|
|
|
|
at tryOnImmediate (timers.js:*:*)
|
|
|
|
at processImmediate [as _immediateCallback] (timers.js:*:*)
|
2012-07-28 23:00:27 +02:00
|
|
|
42
|
|
|
|
42
|
|
|
|
[eval]:1
|
|
|
|
throw new Error("hello")
|
2015-06-19 13:23:56 +02:00
|
|
|
^
|
2012-07-28 23:00:27 +02:00
|
|
|
Error: hello
|
|
|
|
at [eval]:1:7
|
2016-05-08 03:28:47 +02:00
|
|
|
at ContextifyScript.Script.runInThisContext (vm.js:*)
|
vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.
Functionally, this fixes #3042. In particular:
- A context is now indistinguishable from the object it is based on
(the "sandbox"). A context is simply a sandbox that has been marked
by the vm module, via `vm.createContext`, with special internal
information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
immediately visible to all code that can access that context, both
inside and outside the virtual machine.
This commit also smooths over the API very slightly:
- Parameter defaults are now uniformly triggered via `undefined`, per
ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
the conflation of `vm.Script` with `vm` itself, and the fact that
`Script` instances also had all static `vm` methods. The API is now
exactly as documented (although arguably the existence of the
`vm.Script` export is not yet documented, just the `Script` class
itself).
In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.
The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:
- ContextifyScript(code, [filename]), with methods:
- runInThisContext()
- runInContext(sandbox, [timeout])
- makeContext(sandbox)
From this, the vm.js file builds the entire documented vm module API.
node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.
The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.
New tests were also added, of course, demonstrating the new
capabilities and fixes.
[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-07-27 06:34:12 +02:00
|
|
|
at Object.exports.runInThisContext (vm.js:*)
|
2012-08-05 20:26:18 +02:00
|
|
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
|
|
|
at Module._compile (module.js:*:*)
|
2016-09-28 12:01:48 +02:00
|
|
|
at Immediate.<anonymous> (bootstrap_node.js:*:*)
|
|
|
|
at runCallback (timers.js:*:*)
|
|
|
|
at tryOnImmediate (timers.js:*:*)
|
|
|
|
at processImmediate [as _immediateCallback] (timers.js:*:*)
|
2012-07-28 23:00:27 +02:00
|
|
|
[eval]:1
|
|
|
|
throw new Error("hello")
|
2015-06-19 13:23:56 +02:00
|
|
|
^
|
2012-07-28 23:00:27 +02:00
|
|
|
Error: hello
|
|
|
|
at [eval]:1:7
|
2016-05-08 03:28:47 +02:00
|
|
|
at ContextifyScript.Script.runInThisContext (vm.js:*)
|
vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.
Functionally, this fixes #3042. In particular:
- A context is now indistinguishable from the object it is based on
(the "sandbox"). A context is simply a sandbox that has been marked
by the vm module, via `vm.createContext`, with special internal
information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
immediately visible to all code that can access that context, both
inside and outside the virtual machine.
This commit also smooths over the API very slightly:
- Parameter defaults are now uniformly triggered via `undefined`, per
ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
the conflation of `vm.Script` with `vm` itself, and the fact that
`Script` instances also had all static `vm` methods. The API is now
exactly as documented (although arguably the existence of the
`vm.Script` export is not yet documented, just the `Script` class
itself).
In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.
The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:
- ContextifyScript(code, [filename]), with methods:
- runInThisContext()
- runInContext(sandbox, [timeout])
- makeContext(sandbox)
From this, the vm.js file builds the entire documented vm module API.
node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.
The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.
New tests were also added, of course, demonstrating the new
capabilities and fixes.
[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-07-27 06:34:12 +02:00
|
|
|
at Object.exports.runInThisContext (vm.js:*)
|
2012-08-05 20:26:18 +02:00
|
|
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
|
|
|
at Module._compile (module.js:*:*)
|
2016-09-28 12:01:48 +02:00
|
|
|
at Immediate.<anonymous> (bootstrap_node.js:*:*)
|
|
|
|
at runCallback (timers.js:*:*)
|
|
|
|
at tryOnImmediate (timers.js:*:*)
|
|
|
|
at processImmediate [as _immediateCallback] (timers.js:*:*)
|
2012-07-28 23:00:27 +02:00
|
|
|
100
|
|
|
|
[eval]:1
|
|
|
|
var x = 100; y = x;
|
|
|
|
^
|
|
|
|
ReferenceError: y is not defined
|
|
|
|
at [eval]:1:16
|
2016-05-08 03:28:47 +02:00
|
|
|
at ContextifyScript.Script.runInThisContext (vm.js:*)
|
vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.
Functionally, this fixes #3042. In particular:
- A context is now indistinguishable from the object it is based on
(the "sandbox"). A context is simply a sandbox that has been marked
by the vm module, via `vm.createContext`, with special internal
information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
immediately visible to all code that can access that context, both
inside and outside the virtual machine.
This commit also smooths over the API very slightly:
- Parameter defaults are now uniformly triggered via `undefined`, per
ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
the conflation of `vm.Script` with `vm` itself, and the fact that
`Script` instances also had all static `vm` methods. The API is now
exactly as documented (although arguably the existence of the
`vm.Script` export is not yet documented, just the `Script` class
itself).
In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.
The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:
- ContextifyScript(code, [filename]), with methods:
- runInThisContext()
- runInContext(sandbox, [timeout])
- makeContext(sandbox)
From this, the vm.js file builds the entire documented vm module API.
node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.
The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.
New tests were also added, of course, demonstrating the new
capabilities and fixes.
[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-07-27 06:34:12 +02:00
|
|
|
at Object.exports.runInThisContext (vm.js:*)
|
2012-08-05 20:26:18 +02:00
|
|
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
|
|
|
at Module._compile (module.js:*:*)
|
2016-09-28 12:01:48 +02:00
|
|
|
at Immediate.<anonymous> (bootstrap_node.js:*:*)
|
|
|
|
at runCallback (timers.js:*:*)
|
|
|
|
at tryOnImmediate (timers.js:*:*)
|
|
|
|
at processImmediate [as _immediateCallback] (timers.js:*:*)
|
2012-07-28 23:00:27 +02:00
|
|
|
[eval]:1
|
|
|
|
var ______________________________________________; throw 10
|
|
|
|
^
|
|
|
|
10
|
|
|
|
[eval]:1
|
|
|
|
var ______________________________________________; throw 10
|
|
|
|
^
|
|
|
|
10
|
|
|
|
done
|