tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

replacer-function-wrapper.js (1048B)


      1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-json.stringify
      5 description: >
      6  Wrapper is plain extensible object with single data property.
      7 info: |
      8  JSON.stringify ( value [ , replacer [ , space ] ] )
      9 
     10  [...]
     11  9. Let wrapper be ObjectCreate(%ObjectPrototype%).
     12  10. Let status be CreateDataProperty(wrapper, the empty String, value).
     13 includes: [propertyHelper.js]
     14 ---*/
     15 
     16 Object.defineProperty(Object.prototype, '', {
     17  set: function() {
     18    throw new Test262Error('[[Set]] should not be called.');
     19  },
     20 });
     21 
     22 var value = {};
     23 var wrapper;
     24 JSON.stringify(value, function() {
     25  wrapper = this;
     26 });
     27 
     28 assert.sameValue(typeof wrapper, 'object');
     29 assert.sameValue(Object.getPrototypeOf(wrapper), Object.prototype);
     30 assert.sameValue(Object.getOwnPropertyNames(wrapper).length, 1);
     31 assert(Object.isExtensible(wrapper));
     32 
     33 verifyProperty(wrapper, '', {
     34  value: value,
     35  writable: true,
     36  enumerable: true,
     37  configurable: true,
     38 });
     39 
     40 reportCompare(0, 0);