Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sleep in a firefox extension without using setTimeout?

I am trying to open a pop-up window, wait X seconds and then close the popup window.

(The use case is sending a notification to a webapp - but we can't just do a GET request as it needs to be in the same session so we can use the login session)

I can't use setTimeout as we can't use it in add-ons/extensions

How can I get similar functionality without resorting to chewing up CPU cycles, which obviously causes a noticeable lag?

like image 903
Morris Fauntleroy Avatar asked Dec 11 '22 13:12

Morris Fauntleroy


1 Answers

You can use the timers module provided by the SDK instead of nsITimer for the same kind of setTimeout/setInterval functionality provided in browsers

let { setTimeout } = require('sdk/timers');

function openPopup () {}

setTimeout(openPopup, 3000);
like image 111
jsantell Avatar answered Feb 20 '23 22:02

jsantell