tor-browser

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

S8.12.8_A2.js (1047B)


      1 // Copyright 2009 the Sputnik authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 info: |
      6    This should generate no TypeError,
      7    Cause we overload toString method so it return non Primitive value
      8    but we overloaded valueOf method too.
      9    See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325
     10 es5id: 8.12.8_A2
     11 description: >
     12    Try to overload toString, that returned new Object, and valueOf
     13    methods
     14 ---*/
     15 
     16 try
     17 {
     18  var __obj = {
     19    toString: function() {
     20      return new Object();
     21    },
     22    valueOf: function() {
     23      return 1;
     24    }
     25  }
     26  if (String(__obj) !== "1") {
     27    throw new Test262Error('#1.1: var __obj = {toString: function() {return new Object();}, valueOf: function() {return 1;}}; String(__obj) === "1". Actual: ' + (String(__obj)));
     28  }
     29 }
     30 catch (e)
     31 {
     32  throw new Test262Error('#1.2: var __obj = {toString: function() {return new Object();}, valueOf: function() {return 1;}}; String(__obj) === "1". Actual: ' + (e));
     33 }
     34 
     35 reportCompare(0, 0);