Skip to content

Object.defineProperty called inside the vm context fails to copy data properties onto the sandbox #10977

Closed
@AnnaMag

Description

@AnnaMag
  • Version: current master
  • Platform: OS X
  • Subsystem: vm

Data properties defined with the Object.defineProperty call inside the vm context are not copied onto the sandbox in the current master.

Test:

'use strict';

require('../common');
var vm = require('vm');
const util = require('util');

const sandbox = {};
const context = vm.createContext(sandbox);

const code = `
   Object.defineProperty(this, "foo", {value: 5});
`;

const res = vm.runInContext(code, context);

console.log(util.inspect(sandbox)); // returns: {}

In v6.2.0 (homebrew installation):

> node test_setter.js
{ foo: 5 }

Debugging the core shows failure in GlobalPropertySetterCallback.

ctx->sandbox()->Set(property, value);

does not set 'foo' on the sandbox (property and value are as expected). 'foo' is present on the global object, but also not returned by

Local<Array> names = global->GetOwnPropertyNames(context).ToLocalChecked();

in CopyProperties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions