test/script/basic/JDK-8015355.js

Wed, 03 Jun 2015 18:08:57 +0200

author
hannesw
date
Wed, 03 Jun 2015 18:08:57 +0200
changeset 1396
d5a9705a27b1
parent 962
ac62e33a99b0
child 1205
4112748288bb
permissions
-rw-r--r--

8066237: Fuzzing bug: Parser error on optimistic recompilation
Reviewed-by: lagergren, attila

sundar@344 1 /*
sundar@344 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
sundar@344 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
attila@962 4 *
sundar@344 5 * This code is free software; you can redistribute it and/or modify it
sundar@344 6 * under the terms of the GNU General Public License version 2 only, as
sundar@344 7 * published by the Free Software Foundation.
attila@962 8 *
sundar@344 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@344 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@344 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@344 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@344 13 * accompanied this code).
attila@962 14 *
sundar@344 15 * You should have received a copy of the GNU General Public License version
sundar@344 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@344 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
attila@962 18 *
sundar@344 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@344 20 * or visit www.oracle.com if you need additional information or have any
sundar@344 21 * questions.
sundar@344 22 */
sundar@344 23
sundar@344 24 /**
sundar@344 25 * JDK-8015355: Array.prototype functions don't honour non-writable length and / or index properties
attila@962 26 *
sundar@344 27 * @test
sundar@344 28 * @run
sundar@344 29 */
sundar@344 30
sundar@344 31 function check(callback) {
sundar@344 32 try {
sundar@344 33 callback();
sundar@344 34 fail("TypeError expected for " + callback);
sundar@344 35 } catch (e) {
sundar@344 36 if (! (e instanceof TypeError)) {
sundar@344 37 fail("TypeError expected, got " + e);
sundar@344 38 }
sundar@344 39 }
sundar@344 40 }
sundar@344 41
sundar@344 42 var array = Object.defineProperty([],"length", { writable: false });
sundar@344 43
sundar@344 44 check(function() {
sundar@344 45 array.push(0)
sundar@344 46 });
sundar@344 47
sundar@344 48 check(function() {
sundar@344 49 array.pop()
sundar@344 50 });
sundar@344 51
sundar@344 52 check(function() {
sundar@344 53 Object.defineProperty([,,],"0",{ writable: false }).reverse();
sundar@344 54 });
sundar@344 55
sundar@344 56 check(function() {
sundar@344 57 array.shift()
sundar@344 58 });
sundar@344 59
sundar@344 60 check(function() {
sundar@344 61 array.splice(0)
sundar@344 62 });
sundar@344 63
sundar@344 64 check(function() {
sundar@344 65 array.unshift()
sundar@344 66 });
sundar@344 67
sundar@344 68 // try the above via call
sundar@344 69
sundar@344 70 check(function() {
sundar@344 71 Array.prototype.push.call(array, 0);
sundar@344 72 });
sundar@344 73
sundar@344 74 check(function() {
sundar@344 75 Array.prototype.pop.call(array);
sundar@344 76 });
sundar@344 77
sundar@344 78 check(function() {
sundar@344 79 Array.prototype.shift.call(array);
sundar@344 80 });
sundar@344 81
sundar@344 82 check(function() {
sundar@344 83 Array.prototype.unshift.call(array);
sundar@344 84 });
sundar@344 85
sundar@344 86 check(function() {
sundar@344 87 Array.prototype.splice.call(array, 0);
sundar@344 88 });
sundar@344 89
sundar@344 90 check(function() {
sundar@344 91 Array.prototype.reverse.call(Object.defineProperty([,,],"0",{ writable: false }));
sundar@344 92 });
sundar@344 93
sundar@344 94 // try the above via apply
sundar@344 95
sundar@344 96 check(function() {
sundar@344 97 Array.prototype.push.apply(array, [ 0 ]);
sundar@344 98 });
sundar@344 99
sundar@344 100 check(function() {
sundar@344 101 Array.prototype.pop.apply(array);
sundar@344 102 });
sundar@344 103
sundar@344 104 check(function() {
sundar@344 105 Array.prototype.shift.apply(array);
sundar@344 106 });
sundar@344 107
sundar@344 108 check(function() {
sundar@344 109 Array.prototype.unshift.apply(array);
sundar@344 110 });
sundar@344 111
sundar@344 112 check(function() {
sundar@344 113 Array.prototype.splice.apply(array, [ 0 ]);
sundar@344 114 });
sundar@344 115
sundar@344 116 check(function() {
sundar@344 117 Array.prototype.reverse.apply(Object.defineProperty([,,],"0",{ writable: false }));
sundar@344 118 });

mercurial