tor-browser

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

unscopables-strict.js (723B)


      1 // SKIP test262 export
      2 // Pending review.
      3 
      4 // Strict assignment to the name of a property that's masked by @@unscopables
      5 // throws a ReferenceError.
      6 
      7 let env = {k: 1};
      8 let f;
      9 with (env) {
     10    f = function () {
     11        "use strict";
     12        k = 2;
     13    };
     14 }
     15 
     16 f();
     17 assertEq(env.k, 2);
     18 
     19 env[Symbol.unscopables] = {k: true};
     20 assertThrowsInstanceOf(f, ReferenceError);
     21 
     22 // @@unscopables is tested when the LHS of assignment is evaluated, so there is
     23 // no effect on the assignment if it is changed while evaluating the RHS.
     24 let g;
     25 with (env) {
     26    g = function () {
     27        "use strict";
     28        k = (env[Symbol.unscopables].k = true, 3);
     29    }
     30 }
     31 env[Symbol.unscopables].k = false;
     32 g();
     33 assertEq(env.k, 3);
     34 
     35 reportCompare(0, 0);