Commit 7dad47c6 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[inspector] Generate custom previews in the objects creation context.

Generating custom previews can invoke user specified JavaScript (via the
`window.devtoolsFormatters` custom formatters feature). These custom
formatters were previously invoked in the main page context, even for
objects coming from other `<iframe>`s. Instead of using the main
renderer context, we should instead generate the custom preview in the
creation context of the object.

Bug: chromium:997925
Change-Id: Ia07915cff6680153b6727e68117ed565e60bc1c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776093Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63476}
parent 890a3153
......@@ -242,10 +242,10 @@ void bodyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
} // anonymous namespace
void generateCustomPreview(int sessionId, const String16& groupName,
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
v8::MaybeLocal<v8::Value> maybeConfig, int maxDepth,
std::unique_ptr<CustomPreview>* preview) {
v8::Local<v8::Context> context = object->CreationContext();
v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
......
......@@ -13,9 +13,9 @@ namespace v8_inspector {
const int kMaxCustomPreviewDepth = 20;
void generateCustomPreview(
int sessionId, const String16& groupName, v8::Local<v8::Context> context,
v8::Local<v8::Object> object, v8::MaybeLocal<v8::Value> config,
int maxDepth, std::unique_ptr<protocol::Runtime::CustomPreview>* preview);
int sessionId, const String16& groupName, v8::Local<v8::Object> object,
v8::MaybeLocal<v8::Value> config, int maxDepth,
std::unique_ptr<protocol::Runtime::CustomPreview>* preview);
} // namespace v8_inspector
......
......@@ -462,7 +462,7 @@ Response InjectedScript::wrapObjectMirror(
if (!response.isSuccess()) return response;
if (customPreviewEnabled && value->IsObject()) {
std::unique_ptr<protocol::Runtime::CustomPreview> customPreview;
generateCustomPreview(sessionId, groupName, context, value.As<v8::Object>(),
generateCustomPreview(sessionId, groupName, value.As<v8::Object>(),
customPreviewConfig, maxCustomPreviewDepth,
&customPreview);
if (customPreview) (*result)->setCustomPreview(std::move(customPreview));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment