tor-browser

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

message-tostring-abrupt-symbol.js (878B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-aggregate-error
      6 description: >
      7  Abrupt completions of ToString(Symbol message)
      8 info: |
      9  AggregateError ( errors, message )
     10 
     11  ...
     12  5. If message is not undefined, then
     13    a. Let msg be ? ToString(message).
     14    b. Perform ! CreateMethodProperty(O, "message", msg).
     15  6. Return O.
     16 features: [AggregateError, Symbol, Symbol.toPrimitive]
     17 ---*/
     18 
     19 var case1 = Symbol();
     20 
     21 assert.throws(TypeError, () => {
     22  new AggregateError([], case1);
     23 }, 'toPrimitive');
     24 
     25 var case2 = {
     26  [Symbol.toPrimitive]() {
     27    return Symbol();
     28  },
     29  toString() {
     30    throw new Test262Error();
     31  },
     32  valueOf() {
     33    throw new Test262Error();
     34  }
     35 };
     36 
     37 assert.throws(TypeError, () => {
     38  new AggregateError([], case2);
     39 }, 'from ToPrimitive');
     40 
     41 reportCompare(0, 0);