-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
chore: edit globalThis.js to first check for globalThis
#1449
Conversation
What a great PR. I think testing this is not necessary, because to test this we would have to simulate that environment and we would be mostly testing the simulation, since there isn't much logic in there. I think what we need is to add an inline comment with exactly what you just said in the description, so that it's clear why it exists and we can merge it. |
I just looked into the current version of core-js of this, https://github.com/zloirock/core-js/blob/master/packages/core-js/internals/global.js |
Ok, great! Would adding the following comment work?
|
That and also your use case with that execution environment |
That comment has been added! |
merged, thank you, will be released with the next release at some point. I aggregate a bit. |
Released in v10.6.0 |
Corresponding issue (if exists):
N/A, but can create if that would be helpful.
What would you like to add/fix?
Now that
globalThis
is generally available on all the latest platforms,globalThis.js
can be improved by first checking for the presence ofglobalThis
.My motivation: At Agoric, we have a secure version of JavaScript called SES. Under SES,
globalThis
exists, butwindow
,self
, andFunction('return this')()
are all undefined for security reasons. So,jss
was failing for us, but by includingglobalThis
, it will safely succeed even under our security requirements.Todo
I would be happy to add a test, but I wasn't sure what to test and where to put it. It looks like there are no unit tests for
globalThis
. I'm testing locally thatjss
works for me under SES with this change.Add documentation if it changes public API