value-bigint-cross-realm.js (701B)
1 // Copyright 2018 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-serializejsonproperty 6 description: JSON.stringify called with a BigInt object from another realm 7 features: [BigInt, cross-realm] 8 ---*/ 9 10 var other = $262.createRealm().global; 11 var wrapped = other.Object(other.BigInt(100)); 12 13 assert.throws(TypeError, () => JSON.stringify(wrapped), 14 "cross-realm BigInt object without toJSON method"); 15 16 other.BigInt.prototype.toJSON = function () { return this.toString(); }; 17 18 assert.sameValue(JSON.stringify(wrapped), "\"100\"", 19 "cross-realm BigInt object with toJSON method"); 20 21 reportCompare(0, 0);