Closed
Bug 686443
Opened 13 years ago
Closed 13 years ago
Iterations using setTimeout with a timeout of 0 hang the browser
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: weblivz, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.5 Safari/535.2
Steps to reproduce:
Execute the following code:
<html>
<head>
<script>
function doIteration() {
for (i=0;i<10;i++) {
writeOut(i);
//writeOutDirect(i);
}
}
function writeOut(i) {
setTimeout(function () {
document.write(i+'<br/>');
},0);
}
function writeOutDirect(i) {
document.write(i+'<br/>');
}
</script>
</head>
<body onload="doIteration()">
</body>
</html>
Actual results:
The first item in the iteration is written to the browser & it then hangs.
Expected results:
It should have written 0 to 9 in the browser, each on a new line.
Comment 1•13 years ago
|
||
Build identifier: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:9.0a1) Gecko/20110912 Firefox/9.0a1
Build ID: 20110912030829
Confirming the issue on latest nightly build: after the first iteration the browser hangs.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated•13 years ago
|
Assignee: general → nobody
Component: JavaScript Engine → DOM
QA Contact: general → general
I don't see a browser hang here, I just see the spinner continue to spin indefinitely (bug 623880). The browser is completely responsive for me.
I believe the expected behavior here is wrong. The implicit document.open from the first document.write cancels all timeouts created by the script. (http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#dom-document-open, step 11).
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 4•13 years ago
|
||
Great. I found at higher iterations the browser would say "Not responding".
However using document.body.appendChild(t); in place of document.write works fine (a relief given my code needs that to work).
So it's the WebKit versions that are doing it wrong :-)
many thanks Kyle.
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•