Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Destructuring assignment to eval or arguments in destructuring is a SyntaxError
3 load(libdir + "asserts.js");
5 var patterns = [
6 "[_]",
7 "[a, b, _]",
8 "[[_]]",
9 "[[], [{}, [_]]]",
10 "{x:_}",
11 "{x:y, z:_}",
12 "{0:_}",
13 "{_}",
14 //"[..._]"
15 ];
17 // If the assertion below fails, congratulations! It means you have added
18 // spread operator support to destructuring assignment. Simply uncomment the
19 // "[..._]" case above. Then delete this comment and assertion.
20 assertThrowsInstanceOf(() => Function("[...x] = [1]"), ReferenceError);
22 for (var pattern of patterns) {
23 var stmt = pattern + " = obj";
24 if (stmt[0] == "{")
25 stmt = "(" + stmt + ")";
26 stmt += ";"
28 // stmt is a legal statement...
29 Function(stmt);
31 // ...but not if you replace _ with one of these two names.
32 for (var name of ["eval", "arguments"]) {
33 var s = stmt.replace("_", name);
34 assertThrowsInstanceOf(() => Function(s), SyntaxError);
35 assertThrowsInstanceOf(() => eval(s), SyntaxError);
36 assertThrowsInstanceOf(() => eval("'use strict'; " + s), SyntaxError);
37 }
38 }