sundar@538: /* sundar@538: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@538: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@538: * sundar@538: * This code is free software; you can redistribute it and/or modify it sundar@538: * under the terms of the GNU General Public License version 2 only, as sundar@538: * published by the Free Software Foundation. sundar@538: * sundar@538: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@538: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@538: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@538: * version 2 for more details (a copy is included in the LICENSE file that sundar@538: * accompanied this code). sundar@538: * sundar@538: * You should have received a copy of the GNU General Public License version sundar@538: * 2 along with this work; if not, write to the Free Software Foundation, sundar@538: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@538: * sundar@538: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@538: * or visit www.oracle.com if you need additional information or have any sundar@538: * questions. sundar@538: */ sundar@538: sundar@538: /** sundar@538: * JDK-8024174: Setting __proto__ property in Object literal should be supported * sundar@538: * @test sundar@538: * @run sundar@538: */ sundar@538: sundar@538: var p = { foo: function() { print("p.foo"); } }; sundar@538: sundar@538: var obj = { sundar@538: __proto__ : p, sundar@538: bar: 44 sundar@538: }; sundar@538: sundar@538: if (obj.__proto__ !== p || Object.getPrototypeOf(obj) !== p) { sundar@538: fail("obj.__proto__ was not set inside literal"); sundar@538: } sundar@538: sundar@538: if (typeof(obj.foo) !== 'function' || obj.foo !== p.foo) { sundar@538: fail("'obj' failed to inherit 'foo' from 'p'"); sundar@538: } sundar@538: sundar@538: var obj2 = { sundar@538: __proto__: null sundar@538: }; sundar@538: sundar@847: if (Object.getPrototypeOf(obj2) !== null) { sundar@538: fail("obj2.__proto__ was not set to null inside literal"); sundar@538: }