test/script/basic/JDK-8098546.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1410
9dba91416efb
permissions
-rw-r--r--

Merge

hannesw@1410 1 /*
hannesw@1410 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1410 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1410 4 *
hannesw@1410 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1410 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1410 7 * published by the Free Software Foundation.
hannesw@1410 8 *
hannesw@1410 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1410 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1410 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1410 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1410 13 * accompanied this code).
hannesw@1410 14 *
hannesw@1410 15 * You should have received a copy of the GNU General Public License version
hannesw@1410 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1410 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1410 18 *
hannesw@1410 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1410 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1410 21 * questions.
hannesw@1410 22 */
hannesw@1410 23
hannesw@1410 24 /**
hannesw@1410 25 * JDK-8098546: eval within a 'with' leaks definitions into global scope
hannesw@1410 26 *
hannesw@1410 27 * @test
hannesw@1410 28 * @run
hannesw@1410 29 */
hannesw@1410 30
hannesw@1410 31 function func() {
hannesw@1410 32 var obj = { foo: 344 };
hannesw@1410 33 with (obj) {
hannesw@1410 34 eval("var x = foo + 3");
hannesw@1410 35 }
hannesw@1410 36 Assert.assertTrue(obj.x === undefined);
hannesw@1410 37 Assert.assertTrue(x === 347);
hannesw@1410 38 }
hannesw@1410 39
hannesw@1410 40 func();
hannesw@1410 41
hannesw@1410 42 // x should be undefined here
hannesw@1410 43 Assert.assertTrue(typeof x === "undefined");
hannesw@1410 44

mercurial