js/src/jit-test/tests/arguments/defaults-strict-mode.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 load(libdir + "asserts.js");
michael@0 2
michael@0 3 function f1(f=(function () { return typeof this !== "object"; })) { "use strict"; return f; }
michael@0 4 assertEq(f1()(), true);
michael@0 5 function f2(f=(function () { "use strict"; return (function () { return typeof this !== "object"; }) })) { assertEq(typeof this, "object"); return f; }
michael@0 6 assertEq(f2()()(), true);
michael@0 7 function f3(f=(function () { return (function () { return typeof this !== "object"; }) })) { "use strict"; return f; }
michael@0 8 assertEq(f3()()(), true);
michael@0 9 // These should be okay.
michael@0 10 function f4(f=(function () { with (Object) {} }), g=(function () { "use strict"; })) {}
michael@0 11 function f5(g=(function () { "use strict"; }), f=(function () { with (Object) {} })) {}
michael@0 12 function f6(f=(function () { return (x for (y in (function g() {}))); })) {}
michael@0 13
michael@0 14 assertThrowsInstanceOf(function () {
michael@0 15 eval("function f(a=delete x) { 'use strict'; }");
michael@0 16 }, SyntaxError);
michael@0 17 assertThrowsInstanceOf(function () {
michael@0 18 Math.sin(4);
michael@0 19 eval("function f(a='\\251') { 'use strict'; }");
michael@0 20 }, SyntaxError);
michael@0 21 assertThrowsInstanceOf(function () {
michael@0 22 eval("function f(a='\\251', b=delete x) { 'use strict'; }");
michael@0 23 }, SyntaxError);
michael@0 24 assertThrowsInstanceOf(function () {
michael@0 25 eval("function f(a=delete x, b='\\251') { 'use strict'; }");
michael@0 26 }, SyntaxError);
michael@0 27 assertThrowsInstanceOf(function () {
michael@0 28 eval("function f(a=(function () { '\\251'; })) { 'use strict'; }");
michael@0 29 }, SyntaxError);
michael@0 30 assertThrowsInstanceOf(function () {
michael@0 31 eval("function f(a=(function () { with (Object) {} })) { 'use strict'; }");
michael@0 32 }, SyntaxError);
michael@0 33 assertThrowsInstanceOf(function () {
michael@0 34 eval("function f(a=(function (b, b) {})) { 'use strict'; }");
michael@0 35 }, SyntaxError);

mercurial