tor-browser

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

bug-1431353-2.js (1685B)


      1 // |jit-test| skip-if: helperThreadCount() === 0
      2 
      3 // Test off-thread parsing correctly fixes up prototypes of special objects when
      4 // merging back to the target compartment.
      5 
      6 function execOffThread(source)
      7 {
      8    offThreadCompileToStencil(source);
      9    var stencil = finishOffThreadStencil();
     10    return evalStencil(stencil);
     11 }
     12 
     13 function parseModuleOffThread(source)
     14 {
     15    offThreadCompileModuleToStencil(source);
     16    var stencil = finishOffThreadStencil();
     17    return instantiateModuleStencil(stencil);
     18 }
     19 
     20 let a = { x: 1 };
     21 let b = execOffThread("undefined, { x: 1 }")
     22 let c = execOffThread("undefined, { x: 1 }")
     23 
     24 assertEq(Object.getPrototypeOf(a), Object.prototype);
     25 assertEq(Object.getPrototypeOf(b), Object.prototype);
     26 assertEq(Object.getPrototypeOf(c), Object.prototype);
     27 
     28 a = () => 1;
     29 b = execOffThread("() => 1")
     30 c = execOffThread("() => 1")
     31 
     32 assertEq(Object.getPrototypeOf(a), Function.prototype);
     33 assertEq(Object.getPrototypeOf(b), Function.prototype);
     34 assertEq(Object.getPrototypeOf(c), Function.prototype);
     35 
     36 a = [1, 2, 3];
     37 b = execOffThread("[1, 2, 3]")
     38 c = execOffThread("[1, 2, 3]")
     39 
     40 assertEq(Object.getPrototypeOf(a), Array.prototype);
     41 assertEq(Object.getPrototypeOf(b), Array.prototype);
     42 assertEq(Object.getPrototypeOf(c), Array.prototype);
     43 
     44 a = /a/;
     45 b = execOffThread("/a/")
     46 c = execOffThread("/a/")
     47 
     48 assertEq(Object.getPrototypeOf(a), RegExp.prototype);
     49 assertEq(Object.getPrototypeOf(b), RegExp.prototype);
     50 assertEq(Object.getPrototypeOf(c), RegExp.prototype);
     51 
     52 a = parseModule("");
     53 b = parseModuleOffThread("");
     54 c = parseModuleOffThread("");
     55 
     56 assertEq(Object.getPrototypeOf(b), Object.getPrototypeOf(a));
     57 assertEq(Object.getPrototypeOf(c), Object.getPrototypeOf(a));