97fc20f381
This is a reland of 14824520fc
Original change's description:
> [inspector] added Runtime.terminateExecution
>
> Runtime.terminateExecution terminates current or next JavaScript
> call. Termination flag is automatically reset as soon as v8 call
> or microtasks are completed.
>
> R=pfeldman@chromium.org
>
> Bug: chromium:820640
> Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
> Change-Id: Ie21c123be3a61fe25cf6e04c38a8b6c664622ed7
> Reviewed-on: https://chromium-review.googlesource.com/957386
> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
> Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#51912}
Bug: chromium:820640
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I6dd30f65c06c2b7eefd1e7beb9a3cf50ea5bf8cd
Reviewed-on: https://chromium-review.googlesource.com/967323
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52004}
61 lines
2.3 KiB
JavaScript
61 lines
2.3 KiB
JavaScript
// Copyright 2018 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('Tests Runtime.terminateExecution');
|
|
|
|
(async function test() {
|
|
Protocol.Runtime.enable();
|
|
Protocol.Runtime.onConsoleAPICalled(
|
|
message => InspectorTest.logMessage(message.params.args[0]));
|
|
InspectorTest.log(
|
|
'Terminate first evaluation (it forces injected-script-source compilation)');
|
|
await Promise.all([
|
|
Protocol.Runtime.terminateExecution().then(InspectorTest.logMessage),
|
|
Protocol.Runtime.evaluate({expression: 'console.log(42)'})
|
|
.then(InspectorTest.logMessage)
|
|
]);
|
|
|
|
InspectorTest.log('Checks that we reset termination after evaluation');
|
|
InspectorTest.logMessage(
|
|
await Protocol.Runtime.evaluate({expression: 'console.log(42)'}));
|
|
InspectorTest.log(
|
|
'Terminate evaluation when injected-script-source already compiled');
|
|
await Promise.all([
|
|
Protocol.Runtime.terminateExecution().then(InspectorTest.logMessage),
|
|
Protocol.Runtime.evaluate({expression: 'console.log(42)'})
|
|
.then(InspectorTest.logMessage)
|
|
]);
|
|
|
|
InspectorTest.log('Terminate script evaluated with v8 API');
|
|
const terminated =
|
|
Protocol.Runtime.terminateExecution().then(InspectorTest.logMessage);
|
|
contextGroup.addScript('console.log(42)');
|
|
await terminated;
|
|
|
|
InspectorTest.log('Terminate chained callback');
|
|
Protocol.Debugger.enable();
|
|
const paused = Protocol.Debugger.oncePaused();
|
|
await Protocol.Runtime.evaluate({
|
|
expression: `let p = new Promise(resolve => setTimeout(resolve, 0));
|
|
p.then(() => {
|
|
while(true){ debugger; }
|
|
}).then(() => console.log('chained after chained callback'));
|
|
p.then(() => { console.log('another chained callback'); });
|
|
undefined`
|
|
});
|
|
await paused;
|
|
|
|
InspectorTest.log('Pause inside microtask and terminate execution');
|
|
Protocol.Runtime.terminateExecution().then(InspectorTest.logMessage);
|
|
await Protocol.Debugger.resume();
|
|
await Protocol.Runtime
|
|
.evaluate({expression: `console.log('separate eval after while(true)')`})
|
|
.then(InspectorTest.logMessage);
|
|
await Protocol.Debugger.disable();
|
|
|
|
await Protocol.Runtime.disable();
|
|
InspectorTest.completeTest();
|
|
})();
|