Firefox setInterval passes Random number as parameter bug

I was working on a web development project. Until 30 minutes ago, I had discovered something strange with my code. It worked well on IE and Chrome but it created random results on Mozilla Firefox version 3.6.12. So i did some quick alert()s to find out whats went wrong. Surprisingly, I found out that  if you pass a callback function that can accept parameter into setInterval. It will pass random numbers into the callback function when it wasn't suppose to. I tried to start Firefox in safe mode and run the test again. Unfortunately, the bug still exists.

If you're geeky enough to watch the bug live in action just head over the demo page to reproduce the bug.

Update #1: I just tested the code with setTimeout() it seems like setTimeout() is affected as well.
Update #2: I just filed a report at Bugzilla@Mozilla.
Update #3: It was my mistake. :P It isn't a bug but an inconsistency between browsers.

8 条评论:

  1. Lupchung_199311:45 下午

    please open up ucpro.. starforest shut down the server.. thanks

  2. Without the server u create, gaming seems no meaning anymore... please.. i beg u.... reopen the ucpro server.... reopen the less leavers, less mh, less lagger server...

  3. UCPro Need u Mega...

  4. Please open back UCPro ! =(

  5. nanagurl5:50 下午

    i have nothing better to do since ucpro down. so i made a quick search about your problem and i found someone already asked since a year ago:

  6. Hmm... my bad, misunderstood the second parameter as the parameter for callback function. It seems like it is the "lagness" (delay) between each execution.

  7. nanagurl8:26 下午

    ecma didn't specify setInterval/setTimeout to have default handler. it is nothing wrong for firefox to use it as a 'countdown'. thanks to you, now I know how to check the delay when I am 'inside the loop'.

    it is a cool feature but too bad only available in firefox.

  8. The feature is cool but i felt firefox still sucks because it still doesn't follow the ecma standard. Somehow i learned I should avoid callback parameters for setInterval and setTimeout at all cost in the future. 3 major browsers (IE/FX/Chrome) are reacting differently with the parameters..