LibJS: Remove fast array paths in ArrayPrototype::{pop, push}

Unfortunately this fast path leads to problems if Array.prototype is
changed. We probably need to find out some way to optimize these methods
by detecting changes to the prototype or other mechanisms.
This commit is contained in:
davidot 2021-07-07 14:07:56 +02:00 committed by Linus Groh
commit 7310713d11
Notes: sideshowbarker 2024-07-18 10:08:47 +09:00
2 changed files with 15 additions and 16 deletions

View file

@ -26,4 +26,19 @@ describe("normal behavior", () => {
expect(a.pop()).toBeUndefined();
expect(a).toEqual([]);
});
test("array with prototype indexed value", () => {
Array.prototype[1] = 1;
var a = [0];
a.length = 2;
expect(a[1]).toEqual(1);
expect(a.pop()).toEqual(1);
expect(a.length).toEqual(1);
expect(a).toEqual([0]);
expect(a[1]).toEqual(1);
delete Array.prototype[1];
});
});