Skip to content

Commit 7dad47c

Browse files
bmeurerCommit Bot
authored andcommitted
[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/+/1776093 Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Cr-Commit-Position: refs/heads/master@{#63476}
1 parent 890a315 commit 7dad47c

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/inspector/custom-preview.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ void bodyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
242242
} // anonymous namespace
243243

244244
void generateCustomPreview(int sessionId, const String16& groupName,
245-
v8::Local<v8::Context> context,
246245
v8::Local<v8::Object> object,
247246
v8::MaybeLocal<v8::Value> maybeConfig, int maxDepth,
248247
std::unique_ptr<CustomPreview>* preview) {
248+
v8::Local<v8::Context> context = object->CreationContext();
249249
v8::Isolate* isolate = context->GetIsolate();
250250
v8::MicrotasksScope microtasksScope(isolate,
251251
v8::MicrotasksScope::kDoNotRunMicrotasks);

src/inspector/custom-preview.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace v8_inspector {
1313
const int kMaxCustomPreviewDepth = 20;
1414

1515
void generateCustomPreview(
16-
int sessionId, const String16& groupName, v8::Local<v8::Context> context,
17-
v8::Local<v8::Object> object, v8::MaybeLocal<v8::Value> config,
18-
int maxDepth, std::unique_ptr<protocol::Runtime::CustomPreview>* preview);
16+
int sessionId, const String16& groupName, v8::Local<v8::Object> object,
17+
v8::MaybeLocal<v8::Value> config, int maxDepth,
18+
std::unique_ptr<protocol::Runtime::CustomPreview>* preview);
1919

2020
} // namespace v8_inspector
2121

src/inspector/injected-script.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ Response InjectedScript::wrapObjectMirror(
462462
if (!response.isSuccess()) return response;
463463
if (customPreviewEnabled && value->IsObject()) {
464464
std::unique_ptr<protocol::Runtime::CustomPreview> customPreview;
465-
generateCustomPreview(sessionId, groupName, context, value.As<v8::Object>(),
465+
generateCustomPreview(sessionId, groupName, value.As<v8::Object>(),
466466
customPreviewConfig, maxCustomPreviewDepth,
467467
&customPreview);
468468
if (customPreview) (*result)->setCustomPreview(std::move(customPreview));

0 commit comments

Comments
 (0)