Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 }