sundar@513: /* sundar@513: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@513: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@513: * sundar@513: * This code is free software; you can redistribute it and/or modify it sundar@513: * under the terms of the GNU General Public License version 2 only, as sundar@513: * published by the Free Software Foundation. sundar@513: * sundar@513: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@513: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@513: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@513: * version 2 for more details (a copy is included in the LICENSE file that sundar@513: * accompanied this code). sundar@513: * sundar@513: * You should have received a copy of the GNU General Public License version sundar@513: * 2 along with this work; if not, write to the Free Software Foundation, sundar@513: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@513: * sundar@513: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@513: * or visit www.oracle.com if you need additional information or have any sundar@513: * questions. sundar@513: */ sundar@513: sundar@513: /** sundar@513: * JDK-8023368: Instance __proto__ property should exist and be writable. sundar@513: * sundar@513: * @test sundar@513: * @run sundar@513: */ sundar@513: sundar@513: // check that we cannot create __proto__ cycle sundar@513: load("nashorn:mozilla_compat.js"); sundar@513: sundar@513: var obj = {}; sundar@513: var obj2 = Object.create(obj); sundar@513: sundar@513: // attempt to create __proto__ cycle sundar@513: try { sundar@513: obj.__proto__ = obj2; sundar@513: fail("Should have thrown TypeError"); sundar@513: } catch (e) { sundar@513: if (! (e instanceof TypeError)) { sundar@513: fail("Expected TypeError, got " + e); sundar@513: } sundar@513: print(e); sundar@513: }