Merge pull request #1573 from cxielarko/bigint-stringify-cross-realm

Check that JSON.stringify works with BigInt objects from other realms
This commit is contained in:
Rick Waldron 2018-05-29 13:52:23 -04:00 committed by GitHub
commit 5aa5910f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// 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");