diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/JSON/stringify/value-bigint-cross-realm.js')
-rw-r--r-- | js/src/tests/test262/built-ins/JSON/stringify/value-bigint-cross-realm.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/JSON/stringify/value-bigint-cross-realm.js b/js/src/tests/test262/built-ins/JSON/stringify/value-bigint-cross-realm.js new file mode 100644 index 0000000000..a9d54c9e9c --- /dev/null +++ b/js/src/tests/test262/built-ins/JSON/stringify/value-bigint-cross-realm.js @@ -0,0 +1,21 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-serializejsonproperty +description: JSON.stringify called with a BigInt object from another realm +features: [BigInt, cross-realm] +---*/ + +var other = $262.createRealm().global; +var wrapped = other.Object(other.BigInt(100)); + +assert.throws(TypeError, () => JSON.stringify(wrapped), + "cross-realm BigInt object without toJSON method"); + +other.BigInt.prototype.toJSON = function () { return this.toString(); }; + +assert.sameValue(JSON.stringify(wrapped), "\"100\"", + "cross-realm BigInt object with toJSON method"); + +reportCompare(0, 0); |