private Set<String> waitForMacAppQuit(String browser){
  Set<String> runningApps;
  boolean appClosed=true;
  final long startMillis=System.currentTimeMillis();
  final long waitMillis=100;
  do {
    runningApps=runningApplications();
    if (runningApps.contains(browser)) {
      appClosed=false;
      try {
        Thread.sleep(waitMillis);
      }
 catch (      InterruptedException e) {
        return runningApps;
      }
      long currentMillis=System.currentTimeMillis();
      if (currentMillis - startMillis >= MAX_TERMINATE_WAIT_MILLIS)       break;
    }
 else {
      appClosed=true;
    }
  }
 while (!appClosed);
  return runningApps;
}

private Set < String > waitForMacAppQuit ( String browser ) { Set < String > runningApps ; boolean appClosed = true ; final long startMillis = System . currentTimeMillis ( ) ; final long waitMillis = 100 ; do { runningApps = runningApplications ( ) ; if ( runningApps . contains ( browser ) ) { appClosed = false ; try { Thread . sleep ( waitMillis ) ; } catch ( InterruptedException e ) { return runningApps ; } long currentMillis = System . currentTimeMillis ( ) ; if ( currentMillis - startMillis >= MAX_TERMINATE_WAIT_MILLIS ) break ; } else { appClosed = true ; } } while ( ! appClosed ) ; return runningApps ; }
utility function to wait for a mac application to quit . this waits for a maximum of max_terminate_wait_millis . waiting is important because applescript " quit " is not synchronous and launching a url while the browser is quitting is not good . ( see fb - 21879 )
