v8/test/mjsunit/async-stack-traces-prepare-stacktrace-3.js
Matthias Liedtke 319af35d1d [mjsunit] assertEquals: Assert equality of non-enumerable properties too
assertEquals() compares objects by comparing each property for both
objects. This was done by using Object.keys() which however only returns
enumerable properties.
With this change also non-enumerable properties are compared.

Still, the comparison doesn't require the properties to be equal.
So, if one property is marked enumerable in one object but not the
other, the objects would still be considered equal.
This could be adapted in a follow-up CL if desired.
The prototype is still ignored for the comparison.

Change-Id: I1bb9df055bfb764ac1c02d971ac6f4a50f4a98e8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3876384
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83058}
2022-09-08 09:25:26 +00:00

32 lines
815 B
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.
// Flags: --async-stack-traces
// Check that Error.prepareStackTrace properly marks async frames.
Error.prepareStackTrace = (e, frames) => {
assertSame(two, frames[0].getFunction());
assertEquals(two.name, frames[0].getFunctionName());
assertFalse(frames[0].isAsync());
assertSame(one, frames[1].getFunction());
assertEquals(one.name, frames[1].getFunctionName());
assertTrue(frames[1].isAsync());
return frames;
};
async function one(x) {
return await two(x);
}
async function two(x) {
try {
x = await x;
throw new Error();
} catch (e) {
return e.stack;
}
}
one(1).catch(e => setTimeout(_ => {throw e}, 0));