Skip to content

Proxy passed as vm context hides built-in properties. #6158

Closed
@psrok1

Description

@psrok1

Proxy object is not correctly contextified by vm.createContext routine.

I've tried to create vm with traps on global context, so I made one based on Proxy object.
Unfortunately, code executed inside vm doesn't have any access to built-ins.

> vm.runInNewContext("String", {})
[Function: String]
> vm.runInNewContext("String", new Proxy({},{}))
undefined

Passing required built-ins this way:

ctx = new Proxy({String:String}, {})
vm.runInNewContext("String", ctx)

seems to be (a bit dirty) workaround, but it doesn't resolve a problem at all...

vm.runInNewContext("String.prototype.f = function(){}; ''.f()", ctx)
... because passed String differs from used built-in by string literal, so this code raises an exception (''.f is undefined)

Tested on builds from branches node-vee-eight-4.9/5.0
Proxies doesn't work with older V8s and VMs, because of "not an object" bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions