js/src/jit-test/tests/generators/es6-syntax.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Test interactions between ES6 generators and not-yet-standard
michael@0 2 // features.
michael@0 3
michael@0 4 function assertSyntaxError(str) {
michael@0 5 var msg;
michael@0 6 var evil = eval;
michael@0 7 try {
michael@0 8 // Non-direct eval.
michael@0 9 evil(str);
michael@0 10 } catch (exc) {
michael@0 11 if (exc instanceof SyntaxError)
michael@0 12 return;
michael@0 13 msg = "Assertion failed: expected SyntaxError, got " + exc;
michael@0 14 }
michael@0 15 if (msg === undefined)
michael@0 16 msg = "Assertion failed: expected SyntaxError, but no exception thrown";
michael@0 17 throw new Error(msg + " - " + str);
michael@0 18 }
michael@0 19
michael@0 20 // Destructuring binding.
michael@0 21 assertSyntaxError("function* f(x = yield) {}");
michael@0 22 assertSyntaxError("function* f(x = yield 17) {}");
michael@0 23 assertSyntaxError("function* f([yield]) {}");
michael@0 24 assertSyntaxError("function* f({ yield }) {}");
michael@0 25 assertSyntaxError("function* f(...yield) {}");
michael@0 26
michael@0 27 // For each.
michael@0 28 assertSyntaxError("for yield");
michael@0 29 assertSyntaxError("for yield (;;) {}");
michael@0 30 assertSyntaxError("for yield (x of y) {}");
michael@0 31 assertSyntaxError("for yield (var i in o) {}");
michael@0 32
michael@0 33 // Expression bodies.
michael@0 34 assertSyntaxError("function* f() yield 7");

mercurial