Update waitfor.js

Added a onTimeOut parameter for waitFor function. On most of the occasions, after timeout, we like to execute some other code rather than exit.