Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,19 @@ Intercepted ContextifyContext::PropertyQueryCallback(
if (!maybe_attr.FromMaybe(false)) {
return Intercepted::kNo;
}

// Function declarations can be reflected as configurable sandbox
// properties while V8 tracks their non-configurable global bindings.
PropertyAttribute global_attr;
if (ctx->global_proxy()
->GetRealNamedPropertyAttributes(context, property)
.To(&global_attr)) {
attr = static_cast<PropertyAttribute>(
static_cast<int>(attr) |
(static_cast<int>(global_attr) &
static_cast<int>(PropertyAttribute::DontDelete)));
}

args.GetReturnValue().Set(attr);
return Intercepted::kYes;
} else {
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-vm-global-restricted-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ assert.throws(
() => vm.runInContext('let foo = 2;', ctx),
vm.runInContext('SyntaxError', ctx),
);

// Global function declarations create non-configurable bindings even
// though the corresponding sandbox properties are configurable.
vm.runInContext('function bar() {}', ctx);
assert.throws(
() => vm.runInContext('let bar;', ctx),
vm.runInContext('SyntaxError', ctx),
);
Loading