You can use nsITimer.
Below is a basic example, but you can find more information (including using Components.interfaces.nsITimer.TYPE_REPEATING_SLACK as an alternative to setInterval) on the corresponding documentation page at https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsITimer
// we need an nsITimerCallback compatible interface for the callbacks. var event = { notify: function(timer) { alert("Fire!"); } } // Create the timer... var timer = Components.classes["@mozilla.org/timer;1"] .createInstance(Components.interfaces.nsITimer); // initialize it to call event.notify() once after exactly ten seconds. timer.initWithCallback(event,10000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
source share