All pastes #993748 Raw Edit

Someone

public text v1 · immutable
#993748 ·published 2008-04-22 20:37 UTC
rendered paste body
Test 1 nsITimerCallbackJSFunc.js:

function RUNASYNC()
{
    var timer = Cc["@mozilla.org/timer;1"].createInstance(CI.nsITimer);
    timer.initWithCallback(function ()
    {
        DONE();
    }, 0, CI.nsITimer.TYPE_ONE_SHOT);
}



Test 2 nsITimerCallbackIDL.js:

function ttRunAsyncTimerCallback(func)
{
    assert(typeof func == "function", "please pass a JS function");
    this._func = func;
}
ttRunAsyncTimerCallback.prototype =
{
    _func : null,
    notify : function(timer)
    {
        this._func();
    },
    QueryInterface : function(iid)
    {
        if (iid.equals(CI.nsITimerCallback) ||
            iid.equals(CI.nsISupports))
            return this;
       throw Components.results.NS_NOINTERFACE;
    }
}

function RUNASYNC()
{
    var timer = Cc["@mozilla.org/timer;1"].createInstance(CI.nsITimer);
    timer.initWithCallback(new ttRunAsyncTimerCallback(function ()
    {
        DONE();
    }), 0, CI.nsITimer.TYPE_ONE_SHOT);
}