waitForTest = function(done, fail) {
    // executeScript runs the passed method in the "window" context of
    // the current test. JSUnit exposes hooks into the test's status through
    // the "G_testRunner" global object.
    browser.executeScript(function() {
      if (window['G_testRunner'] && window['G_testRunner']['isFinished']()) {
        return {
          isFinished: true,
          isSuccess: window['G_testRunner']['isSuccess'](),
          report: window['G_testRunner']['getReport']()
        };
      } else {
        return {'isFinished': false};
      }
    }).then(function(status) {
      if (status && status.isFinished) {
        done(status);
      } else {
        waitForTest(done, fail);
      }
    }, function(err) {
      // This can happen if the webdriver had an issue executing the script.
      fail(err);
    });
  }
Waits for current tests to be executed.
@param {function(!Object)} done The function called when the test is finished.
@param {function(!Error)} fail The function called when an unrecoverable error
    happened during the test.