test/script/basic/nonextensible_proto_assign.js

Wed, 18 Jun 2014 12:35:42 -0700

author
katleman
date
Wed, 18 Jun 2014 12:35:42 -0700
changeset 863
6e9c4e34bc61
parent 537
b5ff11e00050
child 952
6d5471a497fb
permissions
-rw-r--r--

Added tag jdk8u20-b19 for changeset b047df215de4

sundar@513 1 /*
sundar@513 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
sundar@513 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sundar@513 4 *
sundar@513 5 * This code is free software; you can redistribute it and/or modify it
sundar@513 6 * under the terms of the GNU General Public License version 2 only, as
sundar@513 7 * published by the Free Software Foundation.
sundar@513 8 *
sundar@513 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@513 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@513 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@513 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@513 13 * accompanied this code).
sundar@513 14 *
sundar@513 15 * You should have received a copy of the GNU General Public License version
sundar@513 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@513 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sundar@513 18 *
sundar@513 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@513 20 * or visit www.oracle.com if you need additional information or have any
sundar@513 21 * questions.
sundar@513 22 */
sundar@513 23
sundar@513 24 /**
sundar@513 25 * JDK-8023368: Instance __proto__ property should exist and be writable.
sundar@513 26 *
sundar@513 27 * @test
sundar@513 28 * @run
sundar@513 29 */
sundar@513 30
sundar@513 31 // check that we cannot assign to __proto__ of a non-extensible object
sundar@513 32 try {
sundar@513 33 var obj = {}
sundar@513 34 Object.preventExtensions(obj);
sundar@513 35 obj.__proto__ = { };
sundar@513 36 fail("Should have thrown TypeError");
sundar@513 37 } catch (e) {
sundar@513 38 if (! (e instanceof TypeError)) {
sundar@513 39 fail("Expected TypeError, got " + e);
sundar@513 40 }
sundar@513 41 print(e);
sundar@513 42 }

mercurial