Commit ea42cf70 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[debugger] Report function proxies as proxies, not as functions

This CL fixes a bug where function proxies were reported as functions
instead as proxies to devtools, which caused dev-tools to call methods
on the function, possibly triggering side-effects.

Change-Id: I1d5d234b784601bd4b7ec91107e4b0cf0d877d07
Bug: chromium:995753
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1762303Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63307}
parent 18cdc2f0
...@@ -1614,13 +1614,13 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context, ...@@ -1614,13 +1614,13 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context,
value, RemoteObject::SubtypeEnum::Regexp, value, RemoteObject::SubtypeEnum::Regexp,
descriptionForRegExp(isolate, value.As<v8::RegExp>())); descriptionForRegExp(isolate, value.As<v8::RegExp>()));
} }
if (value->IsFunction()) {
return v8::base::make_unique<FunctionMirror>(value);
}
if (value->IsProxy()) { if (value->IsProxy()) {
return v8::base::make_unique<ObjectMirror>( return v8::base::make_unique<ObjectMirror>(
value, RemoteObject::SubtypeEnum::Proxy, "Proxy"); value, RemoteObject::SubtypeEnum::Proxy, "Proxy");
} }
if (value->IsFunction()) {
return v8::base::make_unique<FunctionMirror>(value);
}
if (value->IsDate()) { if (value->IsDate()) {
return v8::base::make_unique<ObjectMirror>( return v8::base::make_unique<ObjectMirror>(
value, RemoteObject::SubtypeEnum::Date, value, RemoteObject::SubtypeEnum::Date,
......
...@@ -259,6 +259,7 @@ expression: Promise.resolve(42) ...@@ -259,6 +259,7 @@ expression: Promise.resolve(42)
value : 42 value : 42
} }
Running test: privateNames Running test: privateNames
expression: new class { #foo = 1; #bar = 2; baz = 3;} expression: new class { #foo = 1; #bar = 2; baz = 3;}
{ {
...@@ -295,3 +296,18 @@ expression: new class extends class { #baz = 3; } { #foo = 1; #bar = 2; } ...@@ -295,3 +296,18 @@ expression: new class extends class { #baz = 3; } { #foo = 1; #bar = 2; }
} }
expression: new class extends class { constructor() { return new Proxy({}, {}); } } { #foo = 1; #bar = 2; } expression: new class extends class { constructor() { return new Proxy({}, {}); } } { #foo = 1; #bar = 2; }
Running test: functionProxy
expression: new Proxy(() => {}, { get: () => x++ })
{
name : length
type : number
value : 0
}
{
name : name
type : string
value :
}
...@@ -82,6 +82,12 @@ InspectorTest.runTestSuite([ ...@@ -82,6 +82,12 @@ InspectorTest.runTestSuite([
.then(() => checkExpression("new class extends class { #baz = 3; } { #foo = 1; #bar = 2; }")) .then(() => checkExpression("new class extends class { #baz = 3; } { #foo = 1; #bar = 2; }"))
.then(() => checkExpression("new class extends class { constructor() { return new Proxy({}, {}); } } { #foo = 1; #bar = 2; }")) .then(() => checkExpression("new class extends class { constructor() { return new Proxy({}, {}); } } { #foo = 1; #bar = 2; }"))
.then(next); .then(next);
},
function functionProxy(next)
{
checkExpression("new Proxy(() => {}, { get: () => x++ })")
.then(next);
} }
]); ]);
......
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