summaryrefslogtreecommitdiffstats
path: root/js/src/tests
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 13:02:16 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:09 -0400
commit5e76f72c539cd0e2fc0d38e4475f494868b5e859 (patch)
tree78046947a2841bd399c60ab283e1e80003ab76b0 /js/src/tests
parentbf2610c0cfc96327178a5d3d7121181c2f375f48 (diff)
downloadUXP-5e76f72c539cd0e2fc0d38e4475f494868b5e859.tar
UXP-5e76f72c539cd0e2fc0d38e4475f494868b5e859.tar.gz
UXP-5e76f72c539cd0e2fc0d38e4475f494868b5e859.tar.lz
UXP-5e76f72c539cd0e2fc0d38e4475f494868b5e859.tar.xz
UXP-5e76f72c539cd0e2fc0d38e4475f494868b5e859.zip
1315815 - Don't treat async or await as a keyword when they contain escapes.
Diffstat (limited to 'js/src/tests')
-rw-r--r--js/src/tests/ecma_7/AsyncFunctions/async-contains-unicode-escape.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/js/src/tests/ecma_7/AsyncFunctions/async-contains-unicode-escape.js b/js/src/tests/ecma_7/AsyncFunctions/async-contains-unicode-escape.js
new file mode 100644
index 000000000..d53dff696
--- /dev/null
+++ b/js/src/tests/ecma_7/AsyncFunctions/async-contains-unicode-escape.js
@@ -0,0 +1,54 @@
+var BUGNUMBER = 1315815;
+var summary = "async/await containing escapes";
+
+print(BUGNUMBER + ": " + summary);
+
+// Using "eval" as the argument name is fugly, but it means evals below are
+// *direct* evals, and so their effects in the unescaped case won't extend
+// past each separate |test| call (as would happen if we used a different name
+// that made each eval into an indirect eval, affecting code in the global
+// scope).
+function test(code, eval)
+{
+ var unescaped = code.replace("###", "async");
+ var escaped = code.replace("###", "\\u0061");
+
+ assertThrowsInstanceOf(() => eval(escaped), SyntaxError);
+ eval(unescaped);
+}
+
+test("### function f() {}", eval);
+test("var x = ### function f() {}", eval);
+test("### x => {};", eval);
+test("var x = ### x => {}", eval);
+test("### () => {};", eval);
+test("var x = ### () => {}", eval);
+test("### (y) => {};", eval);
+test("var x = ### (y) => {}", eval);
+test("({ ### x() {} })", eval);
+test("var x = ### function f() {}", eval);
+
+if (typeof parseModule === "function")
+ test("export default ### function f() {}", parseModule);
+
+assertThrowsInstanceOf(() => eval("async await => 1;"),
+ SyntaxError);
+assertThrowsInstanceOf(() => eval("async aw\\u0061it => 1;"),
+ SyntaxError);
+
+var async = 0;
+assertEq(\u0061sync, 0);
+
+var obj = { \u0061sync() { return 1; } };
+assertEq(obj.async(), 1);
+
+async = function() { return 42; };
+
+var z = async(obj);
+assertEq(z, 42);
+
+var w = async(obj)=>{};
+assertEq(typeof w, "function");
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);