Closed Bug 304496 Opened 19 years ago Closed 19 years ago

Request alert, confirm, prompt dialog boxes have abort / stop JavaScript button: protects against infinite loop

Categories

(Firefox :: Menus, defect)

defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 61098

People

(Reporter: ezyang, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

It is extremely easy to create infinite loops in JavaScript, and Mozilla already
helps mitigate this problem by prompting a user when a script is running slowly.
However, this is not the case when it comes to dialog boxes (invoked via
alert(), confirm(), prompt()). For instance, take this simple loop.

while (true) {
  alert('Bang!');
}

[ Tested on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10)
Gecko/20050716 Firefox/1.0.6 ]

Even if I press it a million times, I won't be given the option to abort the
JavaScript. I end up having to kill the application via the Task Manager and I
end up losing any other tabs I have open at that point, which is a *major*
inconvenience.

Therefore, I would like to request a new feature, where an extra (preferably
inconspicuous) button is added that allows a user to abort or stop the current
execution of JavaScript on the current instance of the page (if possible,
disable JavaScript completely for that page until it is reloaded). For
convenience, this mechanism could be implemented the same way Mozilla allows you
to terminate scripts that are causing the application to run slowly.

This is not only a detail for malicious scripts, it also helps JavaScript
developers, because if you're developing a tight loop and you forget to
increment i, you may inadvertently cause an infinite loop and have to kill your
current browser window.

PS: Yes I am aware of the great extension NoScript, and no, it won't help
developers who want to execute their JavaScript.

PPS: I'm filing this under critical because it causes you to "lose data." Hope
you don't mind. And also, if there is an unobvious way to solve this problem,
please tell me, and perhaps we can get an enhancement that makes it more obvious
(I couldn't figure it out, anyway).

Reproducible: Always

Steps to Reproduce:
1. Create a blank HTML file, perhaps on your disk, and insert this script:
<script>
while (true) {
  alert('Bang!');
}
</script>
2. Open up Firefox, browse around, get some tabs open
3. Navigate to your created page, watch Firefox repeatedly alert you, and then
try to find a way to close the current page while preserving your other tabs

Actual Results:  
Can't do it, so I used the Task Manager to kill Firefox.

Expected Results:  
Find button that lets me kill JavaScript, and then continue surfing.
Duplicate of/related to Core bug 61098?
(In reply to comment #1)
> Duplicate of/related to Core bug 61098?

Yup, you're right. Arrghh... I tried searching for it... I didn't find it (I
should have known though, It's pretty obvious)... Well, now we have 24 dupes of
that bug... Sorry...

*** This bug has been marked as a duplicate of 61098 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.