JDK-8074021.js revision 1194:bc79173a9e77
1169695Skan/* 2169695Skan * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3169695Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4169695Skan * 5169695Skan * This code is free software; you can redistribute it and/or modify it 6169695Skan * under the terms of the GNU General Public License version 2 only, as 7169695Skan * published by the Free Software Foundation. 8169695Skan * 9169695Skan * This code is distributed in the hope that it will be useful, but WITHOUT 10169695Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11169695Skan * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12169695Skan * version 2 for more details (a copy is included in the LICENSE file that 13169695Skan * accompanied this code). 14169695Skan * 15169695Skan * You should have received a copy of the GNU General Public License version 16169695Skan * 2 along with this work; if not, write to the Free Software Foundation, 17169695Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18169695Skan * 19169695Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20169695Skan * or visit www.oracle.com if you need additional information or have any 21169695Skan * questions. 22169695Skan */ 23169695Skan 24169695Skan/** 25169695Skan * JDK-8074021: Indirect eval fails when used as an element of an array or as a property of an object 26169695Skan * 27169695Skan * @test 28169695Skan * @run 29169695Skan */ 30169695Skan 31169695Skanvar obj = { foo: eval }; 32169695SkanAssert.assertTrue(obj.foo("typeof(print) == 'function'")); 33169695SkanAssert.assertTrue(obj.foo("RegExp instanceof Function")); 34169695SkanAssert.assertEquals(obj.foo("String(new Array(2, 4, 3))"), "2,4,3"); 35169695Skanobj.foo("print('hello')"); 36169695Skan 37169695Skanvar args = [ eval ]; 38169695SkanAssert.assertTrue(args[0]("typeof(print) == 'function'")); 39169695SkanAssert.assertTrue(args[0]("RegExp instanceof Function")); 40169695SkanAssert.assertEquals(args[0]("String(new Array(2, 4, 3))"), "2,4,3"); 41169695Skanargs[0]("print('hello')"); 42169695Skan