js/src/jit-test/tests/jaeger/testIfEqX.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Tests for IFEQX and GOTOX ops.
michael@0 2 function testIfElse() {
michael@0 3 var src =
michael@0 4 "var a = 0;\n" +
michael@0 5 "if (x) {\n";
michael@0 6 for (var i=0; i<7000; i++) {
michael@0 7 src += "a = 1;";
michael@0 8 }
michael@0 9 src += "} else {\n";
michael@0 10 for (var i=0; i<7000; i++) {
michael@0 11 src += "a = 2;";
michael@0 12 }
michael@0 13 src += "}\n";
michael@0 14 src += "return a;";
michael@0 15
michael@0 16 var f = new Function("x", src);
michael@0 17 assertEq(f(true), 1);
michael@0 18 assertEq(f(false), 2);
michael@0 19 assertEq(f([1, 2, 3]), 1);
michael@0 20 assertEq(f(), 2);
michael@0 21 }
michael@0 22 testIfElse();
michael@0 23
michael@0 24 function testWhile() {
michael@0 25 var src =
michael@0 26 "var i = 0, j = 0;\n" +
michael@0 27 "while (i++ < 50) {\n";
michael@0 28 for (var i=0; i<5000; i++) {
michael@0 29 src += "j = i;";
michael@0 30 }
michael@0 31 src += "}\n";
michael@0 32 src += "return j;";
michael@0 33
michael@0 34 var f = new Function(src);
michael@0 35 assertEq(f(), 50);
michael@0 36 }
michael@0 37 testWhile();

mercurial