Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

vm.createContext and inheritance #3884

@jankuca

Description

@jankuca

The VM context created via vm.createContext does only contain own keys of the object passed to it.

var a = { x: 1 };
var b = Object.create(a);

var ctx_a = vm.createContext(a);
var ctx_b = vm.createContext(b);

vm.runInContext('x', ctx_a); // 1
vm.runInContext('x', ctx_b); // ReferenceError: x is not defined

Is this the correct behavior? Is this to prevent functions such as hasOwnProperty to exist in the context?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions