ad884d036f
REPL mode always returns a promise since we basically turn the evaluated script in an async function. More-over, we stash the result as a property on a plain JS object. This prevents promise chains to resolve too far if the result of the evaluation is a promise itself. Long story short, we don't need to wrap REPL mode results in `Promise.resolve`, but can add the then/catch handlers directly. This fixes the DevTools console when working with broken promise polyfills or broken thenables. R=bmeurer@chromium.org Fixed: chromium:1371072 Change-Id: I96aa8eaf5939fdf6231712b047b50fee734efc0b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3929037 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/main@{#83578}
21 lines
623 B
JavaScript
21 lines
623 B
JavaScript
// Copyright 2022 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 {contextGroup, Protocol} = InspectorTest.start(
|
|
"Tests that REPL mode still works even with a broken Promise.prototype.then");
|
|
|
|
(async function() {
|
|
contextGroup.addScript(`
|
|
Promise.prototype.then = () => {throw Error('you shall not evaluate')};
|
|
`);
|
|
|
|
const { result: { result }} = await Protocol.Runtime.evaluate({
|
|
expression: '42',
|
|
replMode: true,
|
|
});
|
|
InspectorTest.logMessage(result);
|
|
|
|
InspectorTest.completeTest();
|
|
})();
|