Debian Codegraph @

js/src/tests/test262/built-ins/Error/isError/non-error-objects-other-realm.js

raw
1 // |reftest| shell-option(--enable-error-iserror) skip-if(!Error.isError||!xulRuntime.shell) -- Error.isError is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Jordan Harband. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-error.iserror
7 description: >
8 Returns false on non-Error objects from a different realm
9 features: [Error.isError, cross-realm]
10 ---*/
11
12 var other = $262.createRealm().global;
13
14 assert.sameValue(Error.isError(new other.Object()), false);
15 assert.sameValue(Error.isError(new other.Array()), false);
16 assert.sameValue(Error.isError(new other.Function('')), false);
17 assert.sameValue(Error.isError(new other.RegExp('a')), false);
18
19 assert.sameValue(Error.isError(other.Error), false);
20 assert.sameValue(Error.isError(other.EvalError), false);
21 assert.sameValue(Error.isError(other.RangeError), false);
22 assert.sameValue(Error.isError(other.ReferenceError), false);
23 assert.sameValue(Error.isError(other.SyntaxError), false);
24 assert.sameValue(Error.isError(other.TypeError), false);
25 assert.sameValue(Error.isError(other.URIError), false);
26
27 if (typeof other.AggregateError !== 'undefined') {
28 assert.sameValue(Error.isError(other.AggregateError), false);
29 }
30 if (typeof other.SuppressedError !== 'undefined') {
31 assert.sameValue(Error.isError(other.SuppressedError), false);
32 }
33
34 reportCompare(0, 0);