tor-browser

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

15.2.3.7-6-a-144.js (952B)


      1 // Copyright (c) 2012 Ecma International.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es5id: 15.2.3.7-6-a-144
      6 description: >
      7    Object.defineProperties -  'O' is an Array, 'name' is the length
      8    property of 'O', test the [[Value]] field of 'desc' is an Object
      9    which has an own valueOf method that returns an object and
     10    toString method that returns a string (15.4.5.1 step 3.c)
     11 ---*/
     12 
     13 var arr = [];
     14 var toStringAccessed = false;
     15 var valueOfAccessed = false;
     16 
     17 Object.defineProperties(arr, {
     18  length: {
     19    value: {
     20      toString: function() {
     21        toStringAccessed = true;
     22        return '2';
     23      },
     24 
     25      valueOf: function() {
     26        valueOfAccessed = true;
     27        return {};
     28      }
     29    }
     30  }
     31 });
     32 
     33 assert.sameValue(arr.length, 2, 'arr.length');
     34 assert(toStringAccessed, 'toStringAccessed !== true');
     35 assert(valueOfAccessed, 'valueOfAccessed !== true');
     36 
     37 reportCompare(0, 0);