The default bug view has changed. See this FAQ.

setTimeout(functionReference, delay, arg) causes two arguments

RESOLVED DUPLICATE of bug 394769

Status

Core Graveyard
Viewer App
P3
normal
RESOLVED DUPLICATE of bug 394769
18 years ago
2 months ago

People

(Reporter: martin.honnen, Assigned: vidur (gone))

Tracking

Trunk
x86
Windows 95

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

18 years ago
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.
(Reporter)

Comment 1

18 years ago
Created attachment 1018 [details]
bug demo

Updated

18 years ago
Assignee: rickg → vidur

Comment 2

18 years ago
Vidur -- one for you I think.
(Assignee)

Updated

18 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 3

18 years ago
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?
(Assignee)

Comment 4

18 years ago
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.
(Assignee)

Comment 5

18 years ago
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

18 years ago
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
(Reporter)

Comment 7

18 years ago
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.

Updated

18 years ago
QA Contact: leger → vidur
(Assignee)

Updated

18 years ago
QA Contact: vidur → desale
(Assignee)

Updated

17 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → WONTFIX
(Assignee)

Comment 8

17 years ago
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

17 years ago
Verified.
Status: RESOLVED → VERIFIED

Comment 10

11 years ago
*** Bug 263945 has been marked as a duplicate of this bug. ***

Comment 11

11 years ago
*** Bug 329160 has been marked as a duplicate of this bug. ***

Updated

9 years ago
Duplicate of this bug: 408378

Comment 13

9 years ago
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.

Product: Core → Core Graveyard

Comment 14

9 years ago
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)
Status: VERIFIED → RESOLVED
Last Resolved: 17 years ago6 years ago
Resolution: WONTFIX → DUPLICATE
Duplicate of bug: 394769
You need to log in before you can comment on or make changes to this bug.