Closed Bug 416912 Opened 17 years ago Closed 16 years ago

Hang with message event and postMessage


(Core :: DOM: UI Events & Focus Handling, defect)

Windows XP
Not set





(Reporter: martijn.martijn, Unassigned)




(Keywords: hang, testcase)


(1 file)

Attached file testcase
See testcase which hangs current trunk build on load, because it's recursively calling postMessages of the message event.
Lame off course, but Mozilla shouldn't hang or at least show a slow script warning or something.

Maybe related to bug 391399, I guess.
So there is JS' 'too much recursion' error, but that doesn't stop the
recursion because there is always another event handler which will
post a new message.
Is something similar to document.write recursion handling needed (Bug 197052)?
Perhaps DOM event dispatching needs recursion limit for this kinds of cases.
(Just recursively dispatching is stopped:
So, looking at this, the first postMessage to child causes one to the parent, which causes two to the child, which causes two to the parent, which cause four to the child, etc. for O(2**n), where n is the recursion limit (check console -- we do hit the JS recursion error).  Based on the recursive thing you mention, this goes to 2**80, so this isn't infinite, just "long enough".  You could construct this with dispatchEvent called twice, I think, for equivalent levels of failure.  However, it *is* a bit curious we're not getting the branch callback called...
An async postMessage makes this go away.  As for the run-forever problem, that seems to have been bug 479430.
Closed: 16 years ago
Resolution: --- → INVALID
So a bug that causes the browser to hang is invalid now?
I dispute the antecedent.  First, it doesn't cause a hang now because it doesn't work -- postMessage takes a mandatory two arguments, not one.  Second, a version modified to pass two arguments (see URL) doesn't hang -- it merely dispatches scads of events and clogs up the event loop, making things really slow, but the browser still runs -- you can even close the faulty tab and go about your business again.
Well, the postMessage function changed, I couldn't know that at that time. I guess it might change again in the future.
If it doesn't hang now anymore, then it seems to me this bug should have been marked worksforme.
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.