allSettled-array-mutation-3.js (520B)
1 let called = 0; 2 let functions = []; 3 class CustomPromise { 4 constructor(executor) { 5 executor(changeArray, changeArray); 6 } 7 static resolve() { 8 return { 9 then: (fulfill, reject) => { 10 functions.push(fulfill, reject); 11 } 12 }; 13 } 14 }; 15 function changeArray(result) { 16 called++; 17 assertEq(result.length, 4); 18 result.length = 0; 19 } 20 Promise.allSettled.call(CustomPromise, [0, 0, 0, 0]); 21 assertEq(functions.length, 8); 22 functions.forEach(f => f()); 23 functions.forEach(f => f()); 24 assertEq(called, 1);