Closed Bug 1281590 Opened 8 years ago Closed 7 years ago

Useless Math.max call in sdk/timers module

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: JoWie, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160604131506

Steps to reproduce:

While browsing the sdk/timers.js module I noticed an useless Math.max call which seems like a mistake: https://dxr.mozilla.org/mozilla-central/source/addon-sdk/source/lib/sdk/timers.js#46

```
try { MIN_DELAY = prefBranch.getIntPref("dom.min_timeout_value"); } finally {}
// ...
timer.initWithCallback({...}, Math.max(delay || MIN_DELAY), type);
```
Assuming `MIN_DELAY` is `4`, `setTimeout(..., 0)` will set a 4ms timeout, however `setTimeout(..., 1)` will set a 1ms timeout.


Because of the name of the variable used (`MIN_DELAY`), I guess something like this was intended:

```
Math.max(delay || MIN_DELAY, MIN_DELAY)
```

However, I am not sure why we would want a minimum delay here; This is used by chrome, not by content.

So I suggest simply changing this to:
```
timer.initWithCallback({...}, delay, type);
```
Which is similar to Timer.jsm
Blocks: sdk/timers
Component: Activity Streams: General → General
Product: Firefox → Add-on SDK
Version: Trunk → unspecified
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.