From 0e2fe0825ae8c521d269f52d4103979c91d2e483 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Fri, 13 Jun 2014 18:44:14 -0700 Subject: [PATCH] Bug 1027693 - Add a test for top-level let not creating a variable that'd show up in |with (global)| scope. r=jorendorff over IRC on original landing, minor adjustments to eliminate a log-highlighting false positive r=trivial --HG-- extra : rebase_source : a43dd2daa969aafbab9d1354c82e2a65ffbdd907 --- js/src/tests/browser.js | 4 +++ .../ecma_6/LexicalEnvironment/browser.js | 0 .../tests/ecma_6/LexicalEnvironment/shell.js | 5 ++++ ...ith-global-ignores-global-let-variables.js | 25 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 js/src/tests/ecma_6/LexicalEnvironment/browser.js create mode 100644 js/src/tests/ecma_6/LexicalEnvironment/shell.js create mode 100644 js/src/tests/ecma_6/LexicalEnvironment/with-global-ignores-global-let-variables.js diff --git a/js/src/tests/browser.js b/js/src/tests/browser.js index 5e59a53558d0..61daf990dd88 100644 --- a/js/src/tests/browser.js +++ b/js/src/tests/browser.js @@ -343,6 +343,10 @@ function jsTestDriverBrowserInit() { properties.version = '1.8'; } + else if (properties.test.match(/^ecma_6\/LexicalEnvironment/)) + { + properties.version = '1.8'; + } } // default to language=type;text/javascript. required for diff --git a/js/src/tests/ecma_6/LexicalEnvironment/browser.js b/js/src/tests/ecma_6/LexicalEnvironment/browser.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/js/src/tests/ecma_6/LexicalEnvironment/shell.js b/js/src/tests/ecma_6/LexicalEnvironment/shell.js new file mode 100644 index 000000000000..4d731295dd21 --- /dev/null +++ b/js/src/tests/ecma_6/LexicalEnvironment/shell.js @@ -0,0 +1,5 @@ +// NOTE: This only turns on 1.8.5 in shell builds. The browser requires the +// futzing in js/src/tests/browser.js (which only turns on 1.8, the most +// the browser supports). +if (typeof version != 'undefined') + version(185); diff --git a/js/src/tests/ecma_6/LexicalEnvironment/with-global-ignores-global-let-variables.js b/js/src/tests/ecma_6/LexicalEnvironment/with-global-ignores-global-let-variables.js new file mode 100644 index 000000000000..0f816ac4c7f1 --- /dev/null +++ b/js/src/tests/ecma_6/LexicalEnvironment/with-global-ignores-global-let-variables.js @@ -0,0 +1,25 @@ +// |reftest| fails-if(Function("try{Function('let\x20x=5;');return(1,eval)('let\x20x=3;\\'x\\'\x20in\x20this');}catch(e){return(true);}")()) -- needs bug 589199 fix (top-level let not same as var); please convert AssertEq to assertEq when removing this fails-if, too +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +let v = "global-v"; + +function f(v, global) +{ + with (global) + return v; +} + +// Don't use assertEq because it triggers tbpl error-highlighting false +// positives. When this test isn't fails-if, just use assertEq directly. +var AssertEq = typeof reportCompare === "function" + ? (act, exp, msg) => reportCompare(exp, act, msg) + : assertEq; + +AssertEq(f("argument-v", this), "argument-v", + "let-var shouldn't appear in global for |with| purposes"); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete");