tor-browser

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

to-primitive-err.js (659B)


      1 // Copyright (C) 2020 Qu Xing. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-escape-string
      5 description: If [Symbol.toPrimitive] method returned an object, it should throw a TypeError
      6 info: |
      7    B.2.1.1 escape ( string )
      8 
      9    1. Let string be ? ToString(string).
     10    ...
     11 features: [Symbol.toPrimitive]
     12 ---*/
     13 
     14 var obj = {
     15  toString() { throw new Test262Error('this should be unreachable'); },
     16  valueOf() { throw new Test262Error('this should be unreachable'); },
     17  [Symbol.toPrimitive]() { return function(){}; }
     18 };
     19 
     20 assert.throws(TypeError, function() {
     21  escape(obj);
     22 });
     23 
     24 reportCompare(0, 0);