In order to fully implement the semantics of perform a security check in WebIDL2JS for use in JSDOM, it’s necessary to be able to get the realm of the caller.
I propose to extend FunctionDeclarationInstantiation with:
9.2.10 FunctionDeclarationInstantiation ( func, argumentsList )
- If argumentsObjectNeeded is true, then
- Let callerContext be the second to top element of the execution context stack.
- Let callerRealm be callerContext's Realm.
- Perform ! DefinePropertyOrThrow(ao, "callerGlobal", PropertyDescriptor { [[Value]]: callerRealm.[[GlobalEnv]].[[GlobalThisValue]], [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- Call env.InitializeBinding("arguments", ao).
This would add a non‑enumerable callerGlobal
property to the arguments
object, which refers to the globalThis
of the caller, making it possible to implement perform a security check in JavaScript.
An option would be to only do that if func
has the [[CaptureCallerGlobal]]
internal slot set to true
, which would be done by the @captureCallerGlobal
built‑in decorator.