1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16{ 17 let arr = new Array(); 18 let length = { 19 valueOf: function() { 20 while (arr.length > 0) { 21 arr.pop(); 22 } 23 return 36; 24 } 25 } 26 for (let i = 0; i < 2; i++) { 27 Array.prototype.slice.apply(arr, [2, length]); 28 arr.splice(length, 2, 127, undefined, 127, undefined); 29 } 30 print(arr.length); 31} 32 33var holey_array = [1, 2, 3, 4, 5,,,,,,]; 34print(holey_array.slice(6, 7)[0]); 35print(holey_array.slice(2, 3)[0]); 36 37(function() { 38 var array = [,]; 39 function slice() { 40 return array.slice(); 41 } 42 array.__proto__.push(5); 43 var narr = slice(); 44 print(Object.getOwnPropertyDescriptor(narr, 0)); 45})(); 46 47 48 49// This use case takes a long time, but the corresponding bug is only repeated in the debug 50let err = []; 51err.length=100; 52let err_len = 0; 53function runNearStackLimit(f) { 54 function t() { 55 try { 56 t(); 57 } catch (e) { 58 err[err_len++]=e; 59 f(); 60 } 61 }; try { 62 t(); 63 } catch (e) { } 64} 65const v7 = new Proxy(String, {}); 66function f0() { 67 v7.bind(); 68} 69runNearStackLimit(f0); 70print("runNearStackLimit test success!");