tor-browser

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

new.target.js (1128B)


      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-scripts-static-semantics-early-errors
      5 es6id: 15.1.1
      6 description: >
      7  An indirect eval may not contain `new.target`
      8 info: |
      9  - It is a Syntax Error if StatementList Contains NewTarget unless the source
     10    code containing NewTarget is eval code that is being processed by a direct
     11    eval that is contained in function code that is not the function code of an
     12    ArrowFunction.
     13 features: [new.target]
     14 ---*/
     15 
     16 var caught;
     17 
     18 try {
     19  (0,eval)('new.target;');
     20 } catch (err) {
     21  caught = err;
     22 }
     23 
     24 assert.sameValue(typeof caught, 'object', 'object value thrown (global code)');
     25 assert.sameValue(
     26  caught.constructor, SyntaxError, 'SyntaxError thrown (global code)'
     27 );
     28 
     29 caught = null;
     30 
     31 try {
     32  (function() {
     33    (0,eval)('new.target;');
     34  })();
     35 } catch (err) {
     36  caught = err;
     37 }
     38 
     39 assert.sameValue(
     40  typeof caught, 'object', 'object value thrown (function code)'
     41 );
     42 assert.sameValue(
     43  caught.constructor, SyntaxError, 'SyntaxError thrown (function code)'
     44 );
     45 
     46 reportCompare(0, 0);