Debian Codegraph @

js/src/tests/test262/harness/asyncHelpers-throwsAsync-same-realm.js

raw
1 // |reftest| async
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: |
6 Thenables that reject with instances of the realm specified constructor function
7 do not satisfy the assertion with cross realms collisions.
8 flags: [async]
9 includes: [asyncHelpers.js]
10 ---*/
11
12 asyncTest(async function () {
13 var intrinsicTypeError = TypeError;
14 var caught = false;
15 var realmGlobal = $262.createRealm().global;
16
17 const p = assert.throwsAsync(TypeError, async function () {
18 throw new realmGlobal.TypeError();
19 });
20 assert(p instanceof Promise);
21 try {
22 await p;
23 } catch (err) {
24 caught = true;
25 assert.sameValue(
26 err.constructor,
27 Test262Error,
28 "Expected a Test262Error, but a '" +
29 err.constructor.name +
30 "' was thrown."
31 );
32 } finally {
33 assert(
34 caught,
35 "assert.throwsAsync did not reject when a different realm's error was thrown"
36 );
37 }
38 });