| 1 |
// |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2023 Ron Buckton. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-suppressederror-constructor |
| 7 |
description: > |
| 8 |
Abrupt completions of ToString(message) |
| 9 |
info: | |
| 10 |
SuppressedError ( error, suppressed, message ) |
| 11 |
|
| 12 |
... |
| 13 |
5. If message is not undefined, then |
| 14 |
a. Let msg be ? ToString(message). |
| 15 |
b. Perform ! CreateMethodProperty(O, "message", msg). |
| 16 |
6. Return O. |
| 17 |
features: [explicit-resource-management, Symbol.toPrimitive] |
| 18 |
---*/ |
| 19 |
|
| 20 |
var case1 = { |
| 21 |
[Symbol.toPrimitive]() { |
| 22 |
throw new Test262Error(); |
| 23 |
}, |
| 24 |
toString() { |
| 25 |
throw 'toString called'; |
| 26 |
}, |
| 27 |
valueOf() { |
| 28 |
throw 'valueOf called'; |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
assert.throws(Test262Error, () => { |
| 33 |
new SuppressedError(undefined, undefined, case1); |
| 34 |
}, 'toPrimitive'); |
| 35 |
|
| 36 |
var case2 = { |
| 37 |
[Symbol.toPrimitive]: undefined, |
| 38 |
toString() { |
| 39 |
throw new Test262Error(); |
| 40 |
}, |
| 41 |
valueOf() { |
| 42 |
throw 'valueOf called'; |
| 43 |
} |
| 44 |
}; |
| 45 |
|
| 46 |
assert.throws(Test262Error, () => { |
| 47 |
new SuppressedError(undefined, undefined, case2); |
| 48 |
}, 'toString'); |
| 49 |
|
| 50 |
var case3 = { |
| 51 |
[Symbol.toPrimitive]: undefined, |
| 52 |
toString: undefined, |
| 53 |
valueOf() { |
| 54 |
throw new Test262Error(); |
| 55 |
} |
| 56 |
}; |
| 57 |
|
| 58 |
assert.throws(Test262Error, () => { |
| 59 |
new SuppressedError(undefined, undefined, case3); |
| 60 |
}, 'valueOf'); |
| 61 |
|
| 62 |
reportCompare(0, 0); |