tor-browser

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

spread-call-this.js (2369B)


      1 let global = this;
      2 let p = {};
      3 let q = {};
      4 
      5 let g1 = function() {
      6  assertEq(this, global);
      7  assertEq(arguments.callee, g1);
      8 };
      9 g1(...[]);
     10 
     11 let g2 = x => {
     12  assertEq(this, global);
     13  // arguments.callee is unbound function object, and following assertion fails.
     14  // see Bug 889158
     15  //assertEq(arguments.callee, g2);
     16 };
     17 g2(...[]);
     18 
     19 let g3 = function() {
     20  assertEq(this, p);
     21  assertEq(arguments.callee, g3);
     22 };
     23 g3.apply(p, ...[]);
     24 g3.call(p, ...[]);
     25 
     26 g2.apply(p, ...[]);
     27 g2.call(p, ...[]);
     28 
     29 let o = {
     30  f1: function() {
     31    assertEq(this, o);
     32    assertEq(arguments.callee, o.f1);
     33 
     34    let g1 = function() {
     35      assertEq(this, global);
     36      assertEq(arguments.callee, g1);
     37    };
     38    g1(...[]);
     39 
     40    let g2 = x => {
     41      assertEq(this, o);
     42      //assertEq(arguments.callee, g2);
     43    };
     44    g2(...[]);
     45 
     46    let g3 = function() {
     47      assertEq(this, q);
     48      assertEq(arguments.callee, g3);
     49    };
     50    g3.apply(q, ...[]);
     51    g3.call(q, ...[]);
     52 
     53    let g4 = x => {
     54      assertEq(this, o);
     55      //assertEq(arguments.callee, g4);
     56    };
     57    g4.apply(q, ...[]);
     58    g4.call(q, ...[]);
     59  },
     60  f2: x => {
     61    assertEq(this, global);
     62    //assertEq(arguments.callee, o.f2);
     63    let g1 = function() {
     64      assertEq(this, global);
     65      assertEq(arguments.callee, g1);
     66    };
     67    g1(...[]);
     68 
     69    let g2 = x => {
     70      assertEq(this, global);
     71      //assertEq(arguments.callee, g2);
     72    };
     73    g2(...[]);
     74 
     75    let g3 = function() {
     76      assertEq(this, q);
     77      assertEq(arguments.callee, g3);
     78    };
     79    g3.apply(q, ...[]);
     80    g3.call(q, ...[]);
     81 
     82    let g4 = x => {
     83      assertEq(this, global);
     84      //assertEq(arguments.callee, g4);
     85    };
     86    g4.apply(q, ...[]);
     87    g4.call(q, ...[]);
     88  },
     89  f3: function() {
     90    assertEq(this, p);
     91    assertEq(arguments.callee, o.f3);
     92 
     93    let g1 = function() {
     94      assertEq(this, global);
     95      assertEq(arguments.callee, g1);
     96    };
     97    g1(...[]);
     98 
     99    let g2 = x => {
    100      assertEq(this, p);
    101      //assertEq(arguments.callee, g2);
    102    };
    103    g2(...[]);
    104 
    105    let g3 = function() {
    106      assertEq(this, q);
    107      assertEq(arguments.callee, g3);
    108    };
    109    g3.apply(q, ...[]);
    110    g3.call(q, ...[]);
    111 
    112    let g4 = x => {
    113      assertEq(this, p);
    114      //assertEq(arguments.callee, g4);
    115    };
    116    g4.apply(q, ...[]);
    117    g4.call(q, ...[]);
    118  }
    119 };
    120 o.f1(...[]);
    121 o.f2(...[]);
    122 o.f3.apply(p, ...[]);
    123 o.f2.apply(p, ...[]);