GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — vm: return all own names and symbols in property enumerator by legendecas · Pull Request #54522 · nodejs/node

Conversation

@legendecas

@legendecas legendecas commented Aug 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Property enumerator methods like Object.getOwnPropertyNames,
Object.getOwnPropertySymbols, and Object.keys all invokes the
named property enumerator interceptor. V8 will filter the result based
on the invoked enumerator variant. Fix the enumerator interceptor to
return all potential properties.

Refs: jsdom/jsdom#3688

/cc @nodejs/vm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with eyes emoji
All reactions
  • 👀 1 reaction
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Aug 23, 2024
@legendecas legendecas mentioned this pull request Aug 23, 2024
vm: introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY #54394
Merged
@joyeecheung

joyeecheung commented Aug 23, 2024

Copy link
Copy Markdown
Member

globalThis[Symbol.toStringTag] was unconditionally initialized
to the sandbox's constructor name, even if it is not present on the
sandbox object.

The original behavior was something like this:

node/src/node_contextify.cc

Line 202 in 5737c21

function_template->SetClassName(sandbox->GetConstructorName());

When we still used a function template's instance template for the global object template. The [Symbol.toStringTag] setting was used to make it look the same while allowing different vm contexts to use different global object templates, so that contexts can share a snapshot. I am not sure how necessary it is to ensure that the globalThis in the new context has the same name as the sandbox's constructor, though. Maybe another alternative is to return something specific for this in the getter/setter/definer interceptors?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Aug 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.31%. Comparing base (cc26951) to head (acf009b).
Report is 354 commits behind head on main.

Files with missing lines Patch % Lines
src/node_contextify.cc 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54522      +/-   ##
==========================================
- Coverage   87.34%   87.31%   -0.03%     
==========================================
  Files         649      649              
  Lines      182544   182759     +215     
  Branches    35030    35048      +18     
==========================================
+ Hits       159445   159579     +134     
- Misses      16372    16459      +87     
+ Partials     6727     6721       -6     
Files with missing lines Coverage Δ
src/node_contextify.cc 80.73% <87.50%> (+0.10%) ⬆️

... and 72 files with indirect coverage changes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@legendecas
legendecas force-pushed the vm/property-enum branch from 66475b7 to d6f5838 Compare August 28, 2024 09:50
@legendecas

legendecas commented Aug 28, 2024

Copy link
Copy Markdown
Member Author

@joyeecheung FunctionTemplate::SetClassName does not set up @@ToStringTag automatically. AFAICT, it is used as the function name and template uniqueness check.

On v18.8.0 where #44252 was not backported, the @@ToStringTag is not installed on the vm globalThis.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Yes, hence it was just done to keep it “look the same as before” (which matters when it gets logged by the console, etc. I don’t know how important it is though, maybe it’s fine to break the display name)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@legendecas
legendecas force-pushed the vm/property-enum branch from d6f5838 to eb35695 Compare August 29, 2024 09:46
@legendecas
vm: return all own names and symbols in property enumerator interceptor
acf009b
Property enumerator methods like `Object.getOwnPropertyNames`,
`Object.getOwnPropertySymbols`, and `Object.keys` all invokes the
named property enumerator interceptor. V8 will filter the result based
on the invoked enumerator variant. Fix the enumerator interceptor to
return all potential properties.
@legendecas
legendecas force-pushed the vm/property-enum branch from eb35695 to acf009b Compare August 29, 2024 09:52
@legendecas

legendecas commented Aug 29, 2024

Copy link
Copy Markdown
Member Author

I left @@toStringTag untouched being an exception as is. The breaking behavior can be a separate PR. This PR still fix inconsistency on Object.getOwnPropertyNames, Object.getOwnPropertySymbols, and Object.keys.

@nodejs/vm @joyeecheung please take a look again, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung approved these changes Aug 29, 2024
View reviewed changes
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 29, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 29, 2024
@nodejs-github-bot

nodejs-github-bot commented Aug 29, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/61654/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 29, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/61664/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@legendecas legendecas added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 30, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 30, 2024
@nodejs-github-bot
nodejs-github-bot merged commit d2479fa into nodejs:main Aug 30, 2024
@nodejs-github-bot

nodejs-github-bot commented Aug 30, 2024

Copy link
Copy Markdown
Collaborator

Landed in d2479fa

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@legendecas
legendecas deleted the vm/property-enum branch August 30, 2024 11:23
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
@legendecas @RafaelGSS
vm: return all own names and symbols in property enumerator interceptor
f67cdf8
Property enumerator methods like `Object.getOwnPropertyNames`,
`Object.getOwnPropertySymbols`, and `Object.keys` all invokes the
named property enumerator interceptor. V8 will filter the result based
on the invoked enumerator variant. Fix the enumerator interceptor to
return all potential properties.

PR-URL: #54522
Refs: jsdom/jsdom#3688
Reviewed-By: Joyee Cheung <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Aug 30, 2024
v22.8.0 proposal #54560
Merged
RafaelGSS pushed a commit that referenced this pull request Sep 1, 2024
@legendecas @RafaelGSS
vm: return all own names and symbols in property enumerator interceptor
fe5666f
Property enumerator methods like `Object.getOwnPropertyNames`,
`Object.getOwnPropertySymbols`, and `Object.keys` all invokes the
named property enumerator interceptor. V8 will filter the result based
on the invoked enumerator variant. Fix the enumerator interceptor to
return all potential properties.

PR-URL: #54522
Refs: jsdom/jsdom#3688
Reviewed-By: Joyee Cheung <[email protected]>
@targos targos added the dont-land-on-v20.x label Sep 22, 2024
@legendecas legendecas mentioned this pull request Jan 7, 2025
runScripts: 'dangerously' changes the output of Object.getOwnPropertyNames(jsdom.window) jsdom/jsdom#3688
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@joyeecheung joyeecheung joyeecheung approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@legendecas @joyeecheung @nodejs-github-bot @targos
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.