Useless Math.max call in sdk/timers module

RESOLVED INCOMPLETE

Status

Add-on SDK
General
RESOLVED INCOMPLETE
2 years ago
3 months ago

People

(Reporter: JoWie, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

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

Updated

2 years ago
Blocks: 1116531
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
Last Resolved: 3 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.