Last Comment Bug 10637 - setTimeout(functionReference, delay, arg) causes two arguments
: setTimeout(functionReference, delay, arg) causes two arguments
Status: RESOLVED DUPLICATE of bug 394769
:
Product: Core Graveyard
Classification: Graveyard
Component: Viewer App (show other bugs)
: Trunk
: x86 Windows 95
: P3 normal (vote)
: ---
Assigned To: vidur (gone)
: Prashant Desale
:
Mentors:
load up a test case afterwards
: 263945 329160 408378 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 1999-07-27 21:54 PDT by martin.honnen
Modified: 2012-02-07 12:45 PST (History)
8 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
bug demo (536 bytes, text/html)
1999-07-27 21:55 PDT, martin.honnen
no flags Details

Description martin.honnen 1999-07-27 21:54:31 PDT
Calling
  setTimeout
or
  setInterbal
with a function reference and a delay causes the called function to have one
additional argument to the passed ones e.g.
 function checkSetTimeout (arg) {
   debug.document.write('arguments.length: ' + arguments.length + '<BR>');
   for (var i = 0; i < arguments.length; i++)
     debug.document.write('arguments[' + i + ']: ' + arguments[i] + '<BR>');
   if (confirm('again'))
     setTimeout (checkSetTimeout, 1000, arg);
 }
 setTimeout (checkSetTimeout, 1000, 'Kibology');
shows
  arguments.length
as
  2
That is actually irking people with NN4 but occurs with mozilla as well. Note
that the example needs the viewer as I used
  confirm
to demonstrate the bug.
I file it on the viewer as I am not sure where js issues not relating to core
ecma belong to.
Comment 1 martin.honnen 1999-07-27 21:55:59 PDT
Created attachment 1018 [details]
bug demo
Comment 2 rickg 1999-07-29 16:17:59 PDT
Vidur -- one for you I think.
Comment 3 vidur (gone) 1999-09-21 22:40:59 PDT
As you mention, this happens with Nav 4.x as well. The implementors of
setTimeout added the extra argument - it is the lateness of the timeout in
milliseconds. Is this truly a problem for JavaScript users?
Comment 4 vidur (gone) 1999-09-23 16:46:59 PDT
Turns out that setTimeout passing in a function argument got busted with
Norris' recent checkin. He passes a JSObject* into
nsIScriptContext::CallFunction() instead oa JSFunction*. Since the
nsIScriptContext interface tries to be language-neutral, void* are passed
around. Hence, the problem wasn't caught by the compiler.
Comment 5 vidur (gone) 1999-10-29 09:05:59 PDT
The timeout problem described in my previous comment has been fixed for a while.
Again, I'd like to understand why that extra argument is a problem. If there's a
compelling reason, I can remove it.

Cc:ing Scott Furman in case he'd like to take part in this discussion.
Comment 6 Scott Furman 1999-10-29 09:15:59 PDT
I doubt that this extra argument is used by anyone, since we never documented
it.  It was very useful to *us* at Netscape in performance testing of animation
using intervals, since a script could detect when the CPU became saturated, i.e.
the timeout lateness was increasing monotonically with each timeout.

Given that it's backward-compatible with NN4, I don't see a reason to change it,
though we might want to finally document it.

There would have to be a pretty compelling reason to
Comment 7 martin.honnen 1999-10-29 10:24:59 PDT
I would prefer to have those arguments in a function I passed in and not one
more, it is particularly troublesome for code looping trough arguments
expecting to process the passed arguments, and the bug report actually resulted
from a newsgroup post where someone wondered why the additional argument is
around so if you decide to keep it at least document it.
Comment 8 vidur (gone) 2000-01-17 22:45:59 PST
Fair enough - this should be documented, but I'd prefer to maintain 4.x
compatibility rather than change this. Marking the bug WONTFIX.
Comment 9 Prashant Desale 2000-01-21 15:17:53 PST
Verified.
Comment 10 Jesse Ruderman 2006-03-02 22:10:46 PST
*** Bug 263945 has been marked as a duplicate of this bug. ***
Comment 11 Jesse Ruderman 2006-03-02 22:10:58 PST
*** Bug 329160 has been marked as a duplicate of this bug. ***
Comment 12 Aiko 2007-12-14 10:01:18 PST
*** Bug 408378 has been marked as a duplicate of this bug. ***
Comment 13 laurent vilday 2008-07-16 02:50:59 PDT
Come on, WONTFIX because of netscape 4.X backward compatibility ?

You can't be serious, are you ?

This is exactly the way Microsoft started to mess up IE 10 years ago.

Is the Mozilla goal is to looks like Microsoft in 10 years from now ?

Come on, fix the bug and get rid of any NS4 backward compatibility, this has to be a joke.

Comment 14 BAM 2008-08-12 22:06:16 PDT
Netscape is no longer a supported browser, OFFICIALLY!  Can you please fix this... (since I have to support all versions of Firefox 1.5+, it won't matter to me today, but I think that backwards compatibility with NN4 should no longer be used as a reason for WONTFIX bugs)
Comment 15 Boris Zbarsky [:bz] (still a bit busy) 2011-03-26 13:08:54 PDT

*** This bug has been marked as a duplicate of bug 394769 ***

Note You need to log in before you can comment on or make changes to this bug.