tor-browser

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

new-9.js (348B)


      1 // Test createThisScripted(), without a singleton.
      2 function Foo(a) {
      3 this.str = "foo";
      4 }
      5 
      6 function Bar(a) {
      7 this.str = "bar";
      8 }
      9 
     10 function f() {
     11 var x;
     12 for (var i = 0; i < 400; i++) {
     13 	if (i % 2 == 0)
     14 		x = Foo;
     15 	else
     16 		x = Bar;
     17 
     18 	var y = new x(5);
     19 
     20 	if (i % 2 == 0)
     21 		assertEq(y.str, "foo");
     22 	else
     23 		assertEq(y.str, "bar");
     24 }
     25 }
     26 
     27 f();