Unable to use window.setTimeout in Ajax Truclient

0

I want to run a function in TruClient (Firefox) every 0.1 seconds using window.setTimeout:

function foobar(delay_accumulator){
    if(delay_accumulator >= 100)//10 seconds
        return;

    //do something
    window.setTimeout(function() { foobar(delay_accumulator+1); }, 100);
}
foobar(0);

However, the step fails, giving the following error:

** 2: Evaluate JavaScript code function foobar(delay_accumula...OBAR"); foobar(0); ** failed - exception occured: NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMJSWindow.setTimeout]

Why is setTimeout not available? Is there an alternative solution I can use?

Edit: Truclient has a "wait" function in the toolbox, but this has a minimum granularity of 1 second as opposed to miliseconds for setTimeout.

javascript
firefox-addon
xpcom
firefox3.6
loadrunner
asked on Stack Overflow Jun 11, 2012 by kxsong • edited Jul 18, 2012 by kxsong

1 Answer

0

Try the nsiTimer: https://developer.mozilla.org/en/nsITimer

answered on Stack Overflow Jun 12, 2012 by Yansky

User contributions licensed under CC BY-SA 3.0