tor-browser

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

value-to-primitive-get-meth-err.js (958B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-date-value
      5 description: Error retrieving `Symbol.toPrimitive` method from object value
      6 info: |
      7  3. If NewTarget is not undefined, then
      8     a. If Type(value) is Object and value has a [[DateValue]] internal slot, then
      9        i. Let tv be thisTimeValue(value).
     10     b. Else,
     11        i. Let v be ? ToPrimitive(value).
     12        [...]
     13 features: [Symbol.toPrimitive]
     14 ---*/
     15 
     16 var poisonedObject = {};
     17 var poisonedDate = new Date();
     18 Object.defineProperty(poisonedObject, Symbol.toPrimitive, {
     19  get: function() {
     20    throw new Test262Error();
     21  }
     22 });
     23 Object.defineProperty(poisonedDate, Symbol.toPrimitive, {
     24  get: function() {
     25    throw new Test262Error();
     26  }
     27 });
     28 
     29 Date(poisonedObject);
     30 
     31 new Date(poisonedDate);
     32 
     33 assert.throws(Test262Error, function() {
     34  new Date(poisonedObject);
     35 });
     36 
     37 reportCompare(0, 0);