hannesw@1329: /* hannesw@1329: * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1329: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1329: * hannesw@1329: * This code is free software; you can redistribute it and/or modify it hannesw@1329: * under the terms of the GNU General Public License version 2 only, as hannesw@1329: * published by the Free Software Foundation. hannesw@1329: * hannesw@1329: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1329: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1329: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1329: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1329: * accompanied this code). hannesw@1329: * hannesw@1329: * You should have received a copy of the GNU General Public License version hannesw@1329: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1329: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1329: * hannesw@1329: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1329: * or visit www.oracle.com if you need additional information or have any hannesw@1329: * questions. hannesw@1329: */ hannesw@1329: hannesw@1329: /** hannesw@1329: * JDK-8077955: Undeclared globals in eval code should not be handled as fast scope hannesw@1329: * hannesw@1329: * @test hannesw@1329: * @run hannesw@1329: * @fork hannesw@1329: * @option -Dnashorn.fields.objects hannesw@1329: */ hannesw@1329: hannesw@1329: var m = new javax.script.ScriptEngineManager(); hannesw@1329: var e = m.getEngineByName('js'); hannesw@1329: hannesw@1329: // leave the whitespace - need both eval("e") at same column for this test! hannesw@1329: hannesw@1329: e.eval('function f(e) { eval("e") } f()'); hannesw@1329: e.eval('function f() { var e = 33; eval("e") } f()'); hannesw@1329: hannesw@1329: function f() { hannesw@1329: Function.call.call(function x() { eval("x") }); eval("x") hannesw@1329: } hannesw@1329: hannesw@1329: try { hannesw@1329: f(); hannesw@1329: fail("Should have thrown ReferenceError"); hannesw@1329: } catch (e) { hannesw@1329: if (! (e instanceof ReferenceError)) { hannesw@1329: fail("ReferenceError expected but got " + e); hannesw@1329: } hannesw@1329: }