function waitForEvent(aEventName) {
    Logger.logInfo("Waiting for " + aEventName + "...");
    let cb = Async.makeSpinningCallback();
    Svc.Obs.add(aEventName, cb);
    cb.wait();
    Svc.Obs.remove(aEventName, cb);
    Logger.logInfo(aEventName + " observed!");

    let cb = Async.makeSpinningCallback();
    Utils.nextTick(cb);
    cb.wait();
  }
/**
   * Synchronously wait for the named event to be observed.
   *
   * When the event is observed, the function will wait an extra tick before
   * returning.
   *
   * @param aEventName
   *        String event to wait for.
   */
Synchronously wait for the named event to be observed.
When the event is observed, the function will wait an extra tick before
returning.

@param aEventName
String event to wait for.
Synchronously wait for the named event to be observed . When the event is observed the function will wait an extra tick before returning . @param aEventName String event to wait for .
function waitForEvent(aEventName) {
    Logger.logInfo("Waiting for " + aEventName + "...");
    let cb = Async.makeSpinningCallback();
    Svc.Obs.add(aEventName, cb);
    cb.wait();
    Svc.Obs.remove(aEventName, cb);
    Logger.logInfo(aEventName + " observed!");
    let cb = Async.makeSpinningCallback();
    Utils.nextTick(cb);
    cb.wait();
  }
function waitForEvent ( aEventName ) { Logger . logInfo ( "Waiting for " + aEventName + "..." ) ; let cb = Async . makeSpinningCallback ( ) ; Svc . Obs . add ( aEventName , cb ) ; cb . wait ( ) ; Svc . Obs . remove ( aEventName , cb ) ; Logger . logInfo ( aEventName + " observed!" ) ; let cb = Async . makeSpinningCallback ( ) ; Utils . nextTick ( cb ) ; cb . wait ( ) ; }
Synchronously wait for the named event to be observed.
Synchronously wait for the named event to be observed .