hannesw@1410: /* hannesw@1410: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1410: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1410: * hannesw@1410: * This code is free software; you can redistribute it and/or modify it hannesw@1410: * under the terms of the GNU General Public License version 2 only, as hannesw@1410: * published by the Free Software Foundation. hannesw@1410: * hannesw@1410: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1410: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1410: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1410: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1410: * accompanied this code). hannesw@1410: * hannesw@1410: * You should have received a copy of the GNU General Public License version hannesw@1410: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1410: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1410: * hannesw@1410: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1410: * or visit www.oracle.com if you need additional information or have any hannesw@1410: * questions. hannesw@1410: */ hannesw@1410: hannesw@1410: /** hannesw@1410: * JDK-8098546: eval within a 'with' leaks definitions into global scope hannesw@1410: * hannesw@1410: * @test hannesw@1410: * @run hannesw@1410: */ hannesw@1410: hannesw@1410: function func() { hannesw@1410: var obj = { foo: 344 }; hannesw@1410: with (obj) { hannesw@1410: eval("var x = foo + 3"); hannesw@1410: } hannesw@1410: Assert.assertTrue(obj.x === undefined); hannesw@1410: Assert.assertTrue(x === 347); hannesw@1410: } hannesw@1410: hannesw@1410: func(); hannesw@1410: hannesw@1410: // x should be undefined here hannesw@1410: Assert.assertTrue(typeof x === "undefined"); hannesw@1410: