Creates a new webdriver session
Gets the driver status
Gets the session status
Resolves the promise (e.g. let them tests run)

@method _startBrowserSession
@param {object} deferred Browser session deferred
@chainable
@private
197554
function (deferred, desiredCapabilities, defaults) {
    var viewport = this.config.get('viewport');

    // start a session, transmit the desired capabilities
    var promise = this.webdriverClient.createSession({desiredCapabilities: desiredCapabilities});
    
    // set the default viewport if supported by the browser
    if (defaults.viewport) {
      promise = promise.then(this.webdriverClient.setWindowSize.bind(this.webdriverClient, viewport.width, viewport.height));
    }

    // get the driver status if supported by the browser
    if (defaults.status === true) {
      promise = promise
        .then(this.webdriverClient.status.bind(this.webdriverClient))
        .then(this._driverStatus.bind(this));
    } else {
      promise = promise.then(this._driverStatus.bind(this, JSON.stringify({value: defaults.status})));
    }

    // get the session info if supported by the browser
    if (defaults.sessionInfo === true) {
      promise = promise
        .then(this.webdriverClient.sessionInfo.bind(this.webdriverClient))
        .then(this._sessionStatus.bind(this));
    } else {
      promise = promise.then(this._driverStatus.bind(this, JSON.stringify({value: defaults.sessionInfo})));
    }

    // finally resolve the deferred
    promise.then(deferred.resolve);
    return this;
  }
110940
function chain(promise,
               onResolve = idResolveHandler,
               onReject = idRejectHandler) {
  var deferred = getDeferred(promise.constructor);
  switch (promise.status_) {
    case undefined:
      throw TypeError;
    case 0:
      promise.onResolve_.push(onResolve, deferred);
      promise.onReject_.push(onReject, deferred);
      break;
    case +1:
      promiseEnqueue(promise.value_, [onResolve, deferred]);
      break;
    case -1:
      promiseEnqueue(promise.value_, [onReject, deferred]);
      break;
  }
  return deferred.promise;
}
435876
function() {
                var deferred = $q.defer();

                this.isAvailable().then(function() {
                    window.ThreeDeeTouch.enableLinkPreview();
                        deferred.resolve(true);
                },
                function(err) {
                    deferred.reject(err);
                });

                return deferred.promise;
            }
1001277
function (sessionInfo) {
    var defer = Q.defer();
    this.sessionStatus = JSON.parse(sessionInfo).value;
    this.events.emit('driver:sessionStatus:sauce:' + this.browserName, this.sessionStatus);
    defer.resolve();
    return defer.promise;
  }
1238638
function getChromeDriverVersion() {
  return new Promise(resolve => {
    const defaultVersion = 'latest';

    matcher.getChromeDriverVersion()
      .then(result => {
        if (result.chromeDriverVersion) {
          resolve(result.chromeDriverVersion);
        } else {
          resolve(defaultVersion);
        }
      })
      .catch(() => resolve(defaultVersion));
  });
}
611783
def _create_session(self):
        
        self.driver = webdriver.Chrome(chrome_options=self.opts, **self.driver_args)
        self.driver.set_window_size(1920, 1080)
466529
function getDriverInstance() {

    var driver;

    switch (browserName || '') {

        case 'firefox': {
            driver = new FireFoxDriver();
        }
            break;

        case 'phantomjs': {
            driver = new PhantomJSDriver();
        }
            break;

        case 'electron': {
            driver = new ElectronDriver();
        }
            break;

        case 'chrome': {
            driver = new ChromeDriver();
        }
            break;

        // try to load from file
        default: {
            var driverFileName = path.resolve(process.cwd(), browserName);

            if (!fs.isFileSync(driverFileName)) {
                throw new Error('Could not find driver file: ' + driverFileName);
            }

            driver = require(driverFileName)();
        }
    }

    return driver;
}
1219390
function makeTask(fetch, deferred) {
  return function start(props, promises, match) {
    var promise = fetch(props, promises, match);

    if (promise.isFulfilled()) {
      deferred.resolve(promise.value());
      return promise;
    } else {
      return promise.then(
        (result) => {
          deferred.resolve(result);
          return result;
        },
        (err) => {
          deferred.reject(err);
          throw err;
        }
      );
    }
  };
}
1265088
function Deferred() {
    var self = this;
    self.promise = new Promise(function (resolve, reject) {
        self.resolve = resolve;
        self.reject = reject;
    });
}
965821
function()
    {
        if (this._executePromise)
            return this._executePromise;

        var q = this.clone();

        var table  = q._T.__name__;
        var page   = q._page;
        var fields = q._fields;

        // Create the query from our stuff
        var query = {};
        _(q._where.concat(q._like)).each(function (q) {
            query[q.key] = q.value;
        });

        var doneLoading      = Q.defer();
        this._executePromise = doneLoading.promise;

        var left = q._take;

        // A single iteration of fetching via the API. Called repeatedly in
        // the case of large / unbounded TAKES
        var loop = function() {

            // always take 1000 unless we're almost done
            var take = left < 1000 ? left : 1000;

            // Hit the API and incremement the page
            q._fetch(table, take, page++, query, fields).then(function(res) {

                // publish progress
                doneLoading.notify(q._results.length);

                if (left !== undefined) left -= res.length;

                // Either resolve the the promise with the results if we're
                // done or call the loop again

                if (q._doneLoading || left <= 0)
                    doneLoading.resolve(q._getResults());
                else
                    process.nextTick(loop);

            }).catch(function(err) {
                doneLoading.reject(err);
            });
        };

        // do tha damn thing
        loop();
        return doneLoading.promise;
    }
867322
function ready(callback = null) {
    let promise = new Promise((resolve) => {
        if (document.readyState === "complete") {
            return resolve();
        }

        document.addEventListener("DOMContentLoaded", () => {
            resolve();
        });
    });

    return (typeof callback === "function") ?
        promise.then(callback) :
        promise;
}
899985
function reload() {
    var defer = q.defer();

    if (browserSync.active) {
        browserSync.reload();
        defer.resolve();
    } else
    startServer().then(defer.resolve);

    return defer.promise;
}
448886
private void start(final WebDriver webDriver, final boolean isResuming) {
        try {
            Validate.validState(isStopped, "The crawler is already running.");
            this.webDriver = Validate.notNull(webDriver, "The webdriver cannot be null.");

            // If the crawl delay strategy is set to adaptive, we check if the browser supports the
            // Navigation Timing API or not. However HtmlUnit requires a page to be loaded first
            // before executing JavaScript, so we load a blank page.
            if (webDriver instanceof HtmlUnitDriver
                    && config.getCrawlDelayStrategy().equals(CrawlDelayStrategy.ADAPTIVE)) {
                webDriver.get(WebClient.ABOUT_BLANK);
            }

            if (!isResuming) {
                crawlFrontier = new CrawlFrontier(config);
            }

            cookieStore = new BasicCookieStore();
            httpClient = HttpClientBuilder.create()
                    .setDefaultCookieStore(cookieStore)
                    .useSystemProperties()
                    .build();
            crawlDelayMechanism = createCrawlDelayMechanism();
            isStopped = false;

            run();
        } finally {
            HttpClientUtils.closeQuietly(httpClient);

            if (this.webDriver != null) {
                this.webDriver.quit();
            }

            isStopping = false;
            isStopped = true;
        }
    }
1047780
def runDeferred(self, deferred):
        
        for handler, scope, offset in deferred:
            self.scopeStack = scope
            self.offset = offset
            handler()
965782
def _connect_deferred(self, deferred):
        
        self._deferred = deferred

        # Because we use __del__, we need to make sure there are no cycles
        # involving this object, which is why we use a weakref:
        def put(result, eventual=weakref.ref(self)):
            eventual = eventual()
            if eventual:
                eventual._set_result(result)
            else:
                err(result, "Unhandled error in EventualResult")

        deferred.addBoth(put)
567395
function (hash, source) {
    var deferred = Q.defer();
    this.events.emit('driver:message', {key: 'source', uuid: hash, hash: hash, value: JSON.parse(source).value});
    deferred.resolve();
    return deferred.promise;
  }
931829
function() {
    var deferred = $q.defer();

    var current = $state.current();

    // Evaluate
    if(current) {
      var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
      
      // Get promises
      $q.all(sources
        .map(function(src) {
          return _createLoadable(src);
        })
        .filter(function(loadable) {
          return !loadable.isComplete;
        })
        .map(function(loadable) {
          return loadable.promise;
        })
      )
          .then(function() {
            deferred.resolve();

          }, function(err) {
            $rootScope.$broadcast('$loadableError', err);
            deferred.reject(err);
          });

    // No state
    } else {
      deferred.resolve();
    }

    return deferred.promise;
  }