I expect every page to have a memory limit similar to the jvm, after which trying to push to the array would result in Error("out of memory")
Perhaps a dialog asking if we want to let the page use more, like the long running script dialog in most browsers.
The sandbox is suppose to protect us from malicious pranks, like browsers these days protect us from an endless loop of alert boxes by asking us if we want to see more, and endless loops in general with the long running terminate dialog.
Personally I'd want something more graceful like halting JS execution on the page and some sort of message...
When I was a teen I rudely tricked a friend to load an infinite alert() page, forcing them to kill their browser and lose some state. These days browsers don't let alerts block switching tabs or closing the offending tab, and with too frequent alerts you can check a box to block any more. It's better.
Expected: Runtime (browser) tries to reallocate the array; requests heap memory from the OS. OS obliges until paging file is full, then warns; browser does something graceful like halting JS on the page. System is slow from disk churning, but nothing crashes.
How is this a bug? What's the expected behavior?