1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * 26 JDK-8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory 27 * 28 * @test 29 * @run 30 */ 31 32 Object.defineProperty(Object.prototype, "accessor", { 33 set: function(value) { 34 print("Setting accessor on " + this + " to " + value); 35 } 36 }); 37 38 Object.defineProperty(Object.prototype, "getterOnly", { 39 get: function() { 40 return 1; 41 } 42 }); 43 44 function set(o) { 45 print("set(" + o + ")"); 46 o.foo = 1; 47 o.constructor = 1; 48 o.accessor = 1; 49 o.getterOnly = 1; 50 print(); 51 } 52 53 function setStrict(o) { 54 "use strict"; 55 print("setStrict(" + o + ")") 56 try { 57 o.foo = 1; 58 } catch (e) { 59 print(e); 60 } 61 try { 62 o.constructor = 1; 63 } catch (e) { 64 print(e); 65 } 66 try { 67 o.accessor = 1; 68 } catch (e) { 69 print(e); 70 } 71 try { 72 o.getterOnly = 1; 73 } catch (e) { 74 print(e); 75 } 76 print(); 77 } 78 79 function setAttr(o, id) { 80 print("setAttr(" + o + ", " + id + ")") 81 o[id] = 1; 82 print(); 83 } 84 85 function setAttrStrict(o, id) { 86 "use strict"; 87 print("setAttrStrict(" + o + ", " + id + ")") 88 try { 89 o[id] = 1; 90 } catch (e) { 91 print(e); 92 } 93 print(); 94 } 95 96 set(1); 97 set("str"); 98 set(true); 99 set({}); 100 set([]); 101 102 setStrict(1); 103 setStrict("str"); 104 setStrict(true); 105 setStrict({}); 106 setStrict([]); 107 108 setAttr(1, "foo"); 109 setAttr(1, "constructor"); 110 setAttr(1, "accessor"); 111 setAttr(1, "getterOnly"); 112 setAttr("str", "foo"); 113 setAttr("str", "constructor"); 114 setAttr("str", "accessor"); 115 setAttr("str", "getterOnly"); 116 setAttr(true, "foo"); 117 setAttr(true, "constructor"); 118 setAttr(true, "accessor"); 119 setAttr(true, "getterOnly"); 120 121 setAttrStrict(1, "foo"); 122 setAttrStrict(1, "constructor"); 123 setAttrStrict(1, "accessor"); 124 setAttrStrict(1, "getterOnly"); 125 setAttrStrict("str", "foo"); 126 setAttrStrict("str", "constructor"); 127 setAttrStrict("str", "accessor"); 128 setAttrStrict("str", "getterOnly"); 129 setAttrStrict(true, "foo"); 130 setAttrStrict(true, "constructor"); 131 setAttrStrict(true, "accessor"); 132 setAttrStrict(true, "getterOnly");