| Index: test/mjsunit/es6/try-catch-for-of.js
|
| diff --git a/test/mjsunit/d8-worker-spawn-worker.js b/test/mjsunit/es6/try-catch-for-of.js
|
| similarity index 73%
|
| copy from test/mjsunit/d8-worker-spawn-worker.js
|
| copy to test/mjsunit/es6/try-catch-for-of.js
|
| index a114d8587e0ebc7095565cfebb3634e7fdefbbe7..560aa3118a287a90148ae5b1f3365bc685602c01 100644
|
| --- a/test/mjsunit/d8-worker-spawn-worker.js
|
| +++ b/test/mjsunit/es6/try-catch-for-of.js
|
| @@ -25,16 +25,30 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -if (this.Worker) {
|
| - var workerScript =
|
| - `var w = new Worker('postMessage(42)');
|
| - onmessage = function(parentMsg) {
|
| - w.postMessage(parentMsg);
|
| - var childMsg = w.getMessage();
|
| - postMessage(childMsg);
|
| - };`;
|
| +// Test that we throw syntax errors when users attempt to shadow
|
| +// try-catch bindings with for-of statements.
|
|
|
| - var w = new Worker(workerScript);
|
| - w.postMessage(9);
|
| - assertEquals(42, w.getMessage());
|
| +function testEarlyError(s) {
|
| + assertThrows(function() {
|
| + eval("(function() { " + s + " })")
|
| + }, SyntaxError);
|
| +}
|
| +
|
| +testEarlyError("try {} catch (e) { for (var e of []) {} }");
|
| +
|
| +assertThrows(function () {
|
| + try {
|
| + throw null;
|
| + } catch (e) {
|
| + eval("for (var e of []) {}");
|
| + }
|
| +}, SyntaxError);
|
| +
|
| +// For-in statements should be fine, though.
|
| +
|
| +try {} catch (f) { for (var f in []) {} }
|
| +try {
|
| + throw null;
|
| +} catch (g) {
|
| + eval("for (var g in []) {}");
|
| }
|
|
|