Endowments are not on the global
See original GitHub issueSince endowments are not accessible on the global it is not possible to match some unsandboxed behavior.
browser example:
this.postMessage === postMessage
//=> true
SES.makeSESRootRealm().evaluate('this.postMessage === postMessage', { postMessage })
//=> false
nodejs example
this.process === process
//=> true
SES.makeSESRootRealm().evaluate('this.process === process', { process })
//=> false
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Understanding Endowments: Types and Policies That ...
An endowment is a donation of money or property to a nonprofit organization, which uses the resulting investment income for a specific purpose....
Read more >Interest Rates Are Rising and the Global Economy Is ...
Endowments shed a median 7.8% in the latest fiscal year, according to Cambridge Associates, against a drop of 10.6% in the S&P 500...
Read more >GLOBAL ENDOWMENT AS A TOOL TO ELIMINATE ...
Endowments (or endowment funds) are legal entities entrusted with financial resources whose proceeds are used for funding charitable activities. Endowments.
Read more >World's largest academic endowment lost money for the ...
Harvard University's endowment lost $2.3 billion in fiscal 2022, blaming the loss on both the global market downturn as well as the university' ......
Read more >Top considerations for Endowments and Foundations in ...
According to Mercer's survey of endowments and foundations, half of respondents cited higher inflation as one of their two main investment ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, only a compartment’s global. The global of an SES root realm must be immutable.
Yes. I’ve been meaning to mention that (especially as this is currently a difference with the XS/tc53 Compartment API).
background:
The endowments are per-evaluation, and emulate the so-called “global lexical scope”, which is closer than the global scope, and which does not correspond to properties on any reified object. (In our shim implementation, they are properties on an internal object, but this object is never revealed.) Outside of the realms and SES shims, AFAIK, no one has ever used the global lexical scope on purpose. It was introduced to the EcmaScript spec to account for top-level
let
,const
, and IIRCclass
declarations, so that they can be shared between scripts without becoming global properties. (Personal note: IMO this entire design was probably a very bad idea, but I did not object at the time, when it would have made a difference.)end background
It is important for us that different evaluations can share the same global while having different endowments. This makes it possible for us to emulate the CommonJS module system, where different modules at different locations in the relative module naming system can be endowed with different
require
functions andmodule
objects while sharing the same global.The workaround for now: After you make a root realm or compartment, but before you evaluate user code in that root realm or compartment, copy the desired global properties onto that global object:
or
The first will only copy enumerable properties, and will invoke getters of accessor properties of the
globalEndowments
. The latter with copy all own properties, and will create new accessors that mimic the old accessors, by reusing the old accessor’s getter and setter functions. I would generally recommend the latter, though it should rarely make a difference.Please let me know if this helps.