Closed
Bug 299476
Opened 19 years ago
Closed 13 years ago
When calling a function via setTimeout() all parameters have to be passed
Categories
(Core Graveyard :: Tracking, defect)
Core Graveyard
Tracking
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 394769
People
(Reporter: whimboo, Unassigned)
References
Details
This bug should be a tracking bug to fix all affected calls of setTimeout().
Calling a function without parameters over setTimeout() will work without any
issue. But don't try to call a function with at least one parameter in that way:
function f (event)
{
alert(typeof(event));
}
setTimeout(f, 100);
In that case RunTimeout doesn't pass an object to f(). Instead an "secret" final
argument that indicates timeout lateness is passed.
See: http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#5248
To avoid such a failure, every function call over setTimeout() has to be
accomplished with the full list of function parameters. The correct way of the
above example would be:
setTimeout(f, 100, null);
Comment 1•19 years ago
|
||
be: This would be a reason not to add lateness to HTML5... :-)
Comment 2•19 years ago
|
||
Indeed!
/be
Summary: When calling a function over setTimeout() all parameters have to be passed → When calling a function via setTimeout() all parameters have to be passed
Comment 3•19 years ago
|
||
Not a DOM bug. I presume this is supposed to track UI bugs caused by this or something?
Assignee: general → chofmann
Component: DOM: Core → Tracking
QA Contact: ian → chofmann
Reporter | ||
Comment 4•19 years ago
|
||
(In reply to comment #3)
> Not a DOM bug. I presume this is supposed to track UI bugs caused by this or
> something?
Correct. I have taken a short look at this issue by querying lxr but wasn't able to find another piece of code. There is already too much use of that function. ;) We have to wait and see.
I can confirm this on:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Comment 6•13 years ago
|
||
Another side effect of this bug is that you can't call functions exposed via Flash's ExternalInterface from window.setTimeout, even if you pass all the parameters. If your ExternalInterface function requires no parameters, window.setTimeout will still pass in the lateness value, which causes the flash plugin to throw this cryptic error message in your js console: "Error calling method on NPObject!" which will be thrown if the wrong number of arguments are passed (either too few or too many).
Comment 7•13 years ago
|
||
Updated•13 years ago
|
Assignee: chofmann → nobody
Comment 8•13 years ago
|
||
(In reply to Philipp von Weitershausen [:philikon] from comment #7)
> Given comment 1 and 2, wouldn't it make more sense to have our
> window.setTimeout implementation not add that lateness parameter, rather
> than fixing all of our own call sites?
Yes - that's bug 394769. I'm not sure what this bug is useful for now.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Updated•8 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•