v8::Object::CreationContext returns the empty handle if the object is a remote object because a remote context does not have any v8::Context (v8::Context::NewRemoteContext only returns a global proxy as v8::Object).
This is problematic because most of Blink codebase is written based on an assumption that, given a v8::Object, the object must make its creation context alive and object->CreationContext() must always return a v8::Context. The assumption is not always true.
This causes a problem especially in case of IDL callback interface. The following code is valid from PoV of standards.
remoteWindow = ...; // e.g. cross origin window with OOPIF
window.addEventListener('foo', remoteWindow);
However, remoteWindow->CreationContext() returns the empty handle, and it makes it hard to implement the rest part of IDL callback interface (e.g. blink::CallbackInterfaceBase).
Possible fix ideas are the followings:
a) Implement v8::RemoteContext derived from v8::Context, and return a v8::RemoteContext in v8::Object::CreationContext. Make v8::RemoteContext super light-weight so that we don't need to create a full features of v8::Context.
b) Implement blink::RemoteScriptState derived from blink::ScriptState, and use it when v8::Object is a remote object. The fundamental idea is the same as a). Just do it inside Blink. (This idea might be hard because ScriptState::GetContext needs to return a v8::Context anyway.)
Comment 1 by yukishiino@chromium.org
, Sep 19