tor-browser

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

module-this.js (582B)


      1 // |jit-test|
      2 // Test 'this' is undefined in modules.
      3 
      4 function parseAndEvaluate(source) {
      5    let m = parseModule(source);
      6    moduleLink(m);
      7    return moduleEvaluate(m);
      8 }
      9 
     10 parseAndEvaluate("this")
     11  .then(value => assertEq(typeof(value), "undefined"))
     12  .catch(error => {
     13    // We shouldn't throw in this case.
     14    assertEq(false, true)
     15  });
     16 
     17 let m = parseModule("export function getThis() { return this; }");
     18 moduleLink(m);
     19 moduleEvaluate(m)
     20  .then(() => {
     21    let f = getModuleEnvironmentValue(m, "getThis");
     22    assertEq(typeof(f()), "undefined");
     23  });
     24 
     25 drainJobQueue();