Cross-context object usage

60 views
Skip to first unread message

ClearScript Developers

unread,
Oct 25, 2021, 4:17:16 PM10/25/21
to v8-users
Greetings!

Can someone confirm that a V8 object can be used safely across contexts within the same isolate?

A related question: What is the significance of an object's creation context?

Also, why don't contexts within the same isolate share built-ins such as Math et al?

Thanks in advance!

Jakob Kummerow

unread,
Oct 25, 2021, 4:59:50 PM10/25/21
to v8-u...@googlegroups.com
Also, why don't contexts within the same isolate share built-ins such as Math et al?

So that one <iframe> can do delete Math.max and any other <iframe>s aren't bothered by that.
(And also because functions have identity and that's observable.)

ClearScript Developers

unread,
Oct 26, 2021, 10:21:43 AM10/26/21
to v8-users
Thanks, Jakob.

It would appear that an object's creation context indicates "which NativeContext initiated a certain action. V8 needs that information for security checks."

Is that correct? An object's creation context is used for security checks? Is there no other significance to it?

(And also because functions have identity and that's observable.)

Could you elaborate on that? What does it mean for a function to have identity? Is it safe, in a given context, to invoke a function that was created in (or is associated with) a different context (in the same isolate, of course)?

Thanks again!
Reply all
Reply to author
Forward
0 new messages