Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying global object (globalThis) #156

Open
JasonBarnabe opened this issue Jan 5, 2020 · 4 comments
Open

Specifying global object (globalThis) #156

JasonBarnabe opened this issue Jan 5, 2020 · 4 comments

Comments

@JasonBarnabe
Copy link

I'm trying to create an environment for scripts that expect to be run in browsers. I can define window, but that doesn't help when the JS is looking at location or document or any other number of things. I presume things like that work because window is the global object, and they're defined there (window.location, window.document, etc.)

Is there a way to specify the global object?

@SamSaffron
Copy link
Collaborator

SamSaffron commented Jan 6, 2020 via email

@JasonBarnabe
Copy link
Author

Maybe walk all the props on window and set them as top level vars?

Yeah, that's the backup plan.

@SamSaffron
Copy link
Collaborator

I am guessing it is something like this:

https://github.com//blob/e5e8685c15494da58112fc1ab76e2dfc15fbf728/test/cctest/test-api-interceptors.cc#L3185-L3185

I support a PR that gives us something like this I guess?

context.global = "{a: 1, b: 2 }"
puts context.eval("a") => 1 

@tisba
Copy link
Collaborator

tisba commented May 30, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants