NASHORN-288.js revision 877:cf4d2252d444
167761Smsmith/* 267761Smsmith * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 367761Smsmith * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 467761Smsmith * 567761Smsmith * This code is free software; you can redistribute it and/or modify it 667761Smsmith * under the terms of the GNU General Public License version 2 only, as 767761Smsmith * published by the Free Software Foundation. 867761Smsmith * 967761Smsmith * This code is distributed in the hope that it will be useful, but WITHOUT 1067761Smsmith * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1167761Smsmith * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1267761Smsmith * version 2 for more details (a copy is included in the LICENSE file that 1367761Smsmith * accompanied this code). 1467761Smsmith * 1567761Smsmith * You should have received a copy of the GNU General Public License version 1667761Smsmith * 2 along with this work; if not, write to the Free Software Foundation, 1767761Smsmith * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1867761Smsmith * 1967761Smsmith * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2067761Smsmith * or visit www.oracle.com if you need additional information or have any 2167761Smsmith * questions. 2267761Smsmith */ 2367761Smsmith 2467761Smsmith/** 2567761Smsmith * NASHORN-288 : Guard setup in ScriptObject.findGetMethod is wrong for inherited properties 2667761Smsmith * 27143002Sobrien * @test 28143002Sobrien * @run 29143002Sobrien */ 30143002Sobrien 3167761Smsmithvar obj1 = {}; 3267761Smsmithobj1.foo = function() { 3379284Smsmith} 34129811Snjl 3579284Smsmithvar obj2 = Object.create(obj1); 36129879Sphk 37221393Sjhb// inside function to force same callsite 38136397Simpfunction func(o) { 3967761Smsmith o.foo(); 40193530Sjkim} 41193530Sjkim 42193530Sjkimfunc(obj2); 4367761Smsmith 4467761Smsmith// change proto's property that is called 4567761Smsmithobj1.foo = 33; 46119281Simp 47119281Simp// try again. should get TypeError as 33 is called 4867761Smsmith// as function! 4967761Smsmithtry { 50102447Sjhb func(obj2); 51102447Sjhb fail("should have thrown TypeError"); 52129811Snjl} catch (e) { 5378993Smsmith if (! (e instanceof TypeError)) { 54102447Sjhb fail("should have thrown TypeError"); 5569744Smsmith } 56102447Sjhb} 5767761Smsmith