582de025d8
A break may cause the session disconnect (and therefore agents destruction) on a nested message loop. The runtime agent code is generally prepared to handle this during evaluate, but the code outside of it may be not. Besides, having a break before the console API installed is generally not what user wants or expects, so just disable all breaks while installing the API. Bug: chromium:1122487 Change-Id: I1d40f5007f2e1e4ec07a50ef57988513d0309b7e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2437383 Commit-Queue: Andrey Kosyakov <caseq@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#70209}
50 lines
1.8 KiB
JavaScript
50 lines
1.8 KiB
JavaScript
// Copyright 2020 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.
|
|
|
|
const {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Check we\'re not pausing on breaks while installing console API');
|
|
|
|
(async function test(){
|
|
// Set up additional console API to give evaluate() a chance to pause
|
|
// there (which it shouldn't) while installing the API upon first eval.
|
|
utils.setAdditionalConsoleApi(`function frobnicate() {
|
|
return [...arguments].reverse().join(' ');
|
|
}`);
|
|
|
|
// Perform self-test, i.e. assure setAdditionalConsoleApi above has effect.
|
|
Protocol.Runtime.enable();
|
|
const expression = 'frobnicate("test", "self")';
|
|
const {result} = await Protocol.Runtime.evaluate({
|
|
expression,
|
|
includeCommandLineAPI: true,
|
|
returnByValue: true
|
|
});
|
|
InspectorTest.log(`${expression} = ${result.result.value}`);
|
|
|
|
// Now for the actual test: get a clean context so that Runtime.evaluate
|
|
// would install the API again.
|
|
const contextGroup = new InspectorTest.ContextGroup();
|
|
const session2 = contextGroup.connect();
|
|
const Protocol2 = session2.Protocol;
|
|
|
|
Protocol2.Runtime.enable();
|
|
Protocol2.Debugger.enable();
|
|
await Protocol2.Debugger.pause();
|
|
|
|
// Add a sourceURL to double check we're paused in the right place.
|
|
const sourceURL = '//# sourceURL=the-right-place.js';
|
|
Protocol2.Runtime.evaluate({
|
|
expression: `frobnicate("real", "test");\n${sourceURL}`,
|
|
includeCommandLineAPI: true
|
|
});
|
|
|
|
const paused = (await Protocol2.Debugger.oncePaused()).params;
|
|
InspectorTest.log(`paused in: ${paused.callFrames[0].url}`);
|
|
|
|
// Now if we're paused in the wrong place, we will likely crash.
|
|
session2.disconnect();
|
|
|
|
InspectorTest.quitImmediately();
|
|
})();
|