v8/test/inspector/regress/regress-crbug-1207867.js
Benedikt Meurer 203f527619 [inspector] Side-effect free FunctionMirror descriptions.
Drive-by-fix: Remove command line API fn.toString() override, which was
still in place from the early days when much of the inspector was
implemented in JavaScript.

Fixed: chromium:1207867
Bug: chromium:1206620
Change-Id: I8429f109da5f021f729f184fd824160a24e60897
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2887508
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74516}
2021-05-12 09:30:37 +00:00

60 lines
1.9 KiB
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Regression test for crbug/1207867');
contextGroup.addScript(`
function fun(x) { return x; }
fun.toString = fn => 'bar';
const arrow = x => x;
arrow.toString = fn => 'baz';
const bound = fun.bind(this);
bound.toString = fn => 'foo';
async function afun(x) { await x; }
afun.toString = fn => 'blah';
const native = Array.prototype.map;
native.toString = fn => 'meh';
`);
InspectorTest.runAsyncTestSuite([
async function testFunctionDescription() {
await Protocol.Runtime.enable();
const {result: {result}} = await Protocol.Runtime.evaluate({expression: 'fun'});
InspectorTest.logMessage(result);
await Protocol.Runtime.disable();
},
async function testArrowFunctionDescription() {
await Protocol.Runtime.enable();
const {result: {result}} = await Protocol.Runtime.evaluate({expression: 'arrow'});
InspectorTest.logMessage(result);
await Protocol.Runtime.disable();
},
async function testBoundFunctionDescription() {
await Protocol.Runtime.enable();
const {result: {result}} = await Protocol.Runtime.evaluate({expression: 'bound'});
InspectorTest.logMessage(result);
await Protocol.Runtime.disable();
},
async function testAsyncFunctionDescription() {
await Protocol.Runtime.enable();
const {result: {result}} = await Protocol.Runtime.evaluate({expression: 'afun'});
InspectorTest.logMessage(result);
await Protocol.Runtime.disable();
},
async function testNativeFunctionDescription() {
await Protocol.Runtime.enable();
const {result: {result}} = await Protocol.Runtime.evaluate({expression: 'native'});
InspectorTest.logMessage(result);
await Protocol.Runtime.disable();
}
]);