Closed Bug 548540 Opened 16 years ago Closed 16 years ago

Add support for repeating timers to timer module

Categories

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

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: adw, Assigned: adw)

References

Details

Attachments

(1 file)

Attached patch patch 1Splinter Review
Simple storage needs to sync to disk periodically. How about adding set/clearInterval to the timer module?
Attachment #428902 - Flags: review?(avarma)
Blocks: 548556
Comment on attachment 428902 [details] [diff] [review] patch 1 Looks great, with this one comment: In the following tests, you may want to do a `test.pass("setInterval() repeats properly");` or something similar just before calling `test.done()`. Right now I don't believe this actually counts as a passed test if it succeeds, though it certainly counts as a failed test if it fails. This could actually be a problem with the timer test suite in general, though, come to think of it--really it's up to you, I guess. It's not that big a deal. > +exports.testSetInterval = function (test) { > + var count = 0; > + var id = timer.setInterval(function () { > + count++; > + if (count >= 5) { > + timer.clearInterval(id); > + test.done(); > + } > + }, 1); > + test.waitUntilDone(); > +}; > + > +exports.testClearInterval = function (test) { > + timer.clearInterval(timer.setInterval(function () { > + test.fail("setInterval callback should not be called"); > + }, 1)); > + var id = timer.setInterval(function () { > + timer.clearInterval(id); > + test.done(); > + }, 2); > + test.waitUntilDone(); > +}; > +
Attachment #428902 - Flags: review?(avarma) → review+
Thanks Atul! Good to know about test.pass(). I went ahead and added that to the other timer tests, since it's changing only a few lines. http://hg.mozilla.org/labs/jetpack-sdk/rev/36a1a31c65ab
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
The Add-on SDK is no longer a Mozilla Labs experiment and has become a big enough project to warrant its own Bugzilla product, so the "Add-on SDK" product has been created for it, and I am moving its bugs to that product. To filter bugmail related to this change, filter on the word "looptid".
Component: Jetpack SDK → General
Product: Mozilla Labs → Add-on SDK
QA Contact: jetpack-sdk → general
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: