Skip to content
Snippets Groups Projects
Commit dbf1362c authored by Robin Templeton's avatar Robin Templeton
Browse files

Check that JSON.stringify works with BigInt objects from other realms

This is based on André Bargull's test case in
<https://bugzilla.mozilla.org/show_bug.cgi?id=1464757>.
parent a8f70125
Branches
No related tags found
No related merge requests found
// 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");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment