tor-browser

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

global-scope.js (925B)


      1 // Test interaction with global object and global lexical scope.
      2 
      3 function evalModuleAndCheck(source, expected) {
      4    let m = parseModule(source);
      5    moduleLink(m);
      6    moduleEvaluate(m);
      7    assertEq(getModuleEnvironmentValue(m, "r"), expected);
      8 }
      9 
     10 var x = 1;
     11 evalModuleAndCheck("export let r = x; x = 2;", 1);
     12 assertEq(x, 2);
     13 
     14 let y = 3;
     15 evalModuleAndCheck("export let r = y; y = 4;", 3);
     16 assertEq(y, 4);
     17 
     18 if (helperThreadCount() == 0)
     19    quit();
     20 
     21 function offThreadEvalModuleAndCheck(source, expected) {
     22    offThreadCompileModuleToStencil(source);
     23    let stencil = finishOffThreadStencil();
     24    let m = instantiateModuleStencil(stencil);
     25    print("compiled");
     26    moduleLink(m);
     27    moduleEvaluate(m);
     28    assertEq(getModuleEnvironmentValue(m, "r"), expected);
     29 }
     30 
     31 offThreadEvalModuleAndCheck("export let r = x; x = 5;", 2);
     32 assertEq(x, 5);
     33 
     34 offThreadEvalModuleAndCheck("export let r = y; y = 6;", 4);
     35 assertEq(y, 6);