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:

    http://stackoverflow.com/questions/2106583/weird-random-value-as-default-interval-handler-parameter

    回复删除
  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..

    回复删除