tor-browser

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

15.2.3.6-4-151.js (1046B)


      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.6-4-151
      6 description: >
      7    Object.defineProperty - 'O' is an Array, 'name' is the length
      8    property of 'O', and the [[Value]] field of 'desc' is an Object
      9    with an own toString method and an inherited valueOf method
     10    (15.4.5.1 step 3.c), test that the inherited valueOf method is used
     11 ---*/
     12 
     13 var arrObj = [];
     14 var toStringAccessed = false;
     15 var valueOfAccessed = false;
     16 
     17 var proto = {
     18  valueOf: function() {
     19    valueOfAccessed = true;
     20    return 2;
     21  }
     22 };
     23 
     24 var ConstructFun = function() {};
     25 ConstructFun.prototype = proto;
     26 
     27 var child = new ConstructFun();
     28 child.toString = function() {
     29  toStringAccessed = true;
     30  return 3;
     31 };
     32 
     33 Object.defineProperty(arrObj, "length", {
     34  value: child
     35 });
     36 
     37 assert.sameValue(arrObj.length, 2, 'arrObj.length');
     38 assert.sameValue(toStringAccessed, false, 'toStringAccessed');
     39 assert(valueOfAccessed, 'valueOfAccessed !== true');
     40 
     41 reportCompare(0, 0);