tor-browser

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

shape-teleporting-2.js (872B)


      1 function A(name) { this.name = name; }
      2 function B() { }
      3 function C() { }
      4 
      5 B.prototype = A0 = new A("0");
      6 C.prototype = B0 = new B();
      7 
      8 var A1 = new A("1");
      9 var A2 = new A("2");
     10 
     11 var B1 = new B();
     12 var B2 = new B();
     13 
     14 var C1 = new C();
     15 var C2 = new C();
     16 
     17 // Object <-+- A0 <-+- B0 <-+
     18 //          |       |       |
     19 //          +- A1   +- B1   +- C1
     20 //          |       |       |
     21 //          +- A2   +- B2   +- C2
     22 
     23 Object.setPrototypeOf(C1, B1);
     24 Object.setPrototypeOf(C2, B2);
     25 
     26 Object.setPrototypeOf(B1, A1);
     27 Object.setPrototypeOf(B2, A2);
     28 
     29 // Object <-+- A0 <--- B0
     30 //          |
     31 //          +- A1 <--- B1 <--- C1
     32 //          |
     33 //          +- A2 <--- B2 <--- C2
     34 
     35 
     36 function getName(o) { return o.name; }
     37 
     38 // Warm up JIT
     39 for (var i = 0; i < 100; i++) {
     40    getName(C1);
     41 }
     42 
     43 assertEq(B1.name, "1");
     44 assertEq(B2.name, "2");
     45 
     46 assertEq(getName(B1), "1");
     47 assertEq(getName(B2), "2");