MCPcopy Create free account
hub / github.com/JacksonTian/fks / Browser

Function Browser

fks_chart/bower_components/angular/angular.js:4387–4752  ·  view source on GitHub ↗

* @param {object} window The global window object. * @param {object} document jQuery wrapped document. * @param {function()} XHR XMLHttpRequest constructor. * @param {object} $log console.log or an object with the same interface. * @param {object} $sniffer $sniffer service

(window, document, $log, $sniffer)

Source from the content-addressed store, hash-verified

4385 * @param {object} $sniffer $sniffer service
4386 */
4387function Browser(window, document, $log, $sniffer) {
4388 var self = this,
4389 rawDocument = document[0],
4390 location = window.location,
4391 history = window.history,
4392 setTimeout = window.setTimeout,
4393 clearTimeout = window.clearTimeout,
4394 pendingDeferIds = {};
4395
4396 self.isMock = false;
4397
4398 var outstandingRequestCount = 0;
4399 var outstandingRequestCallbacks = [];
4400
4401 // TODO(vojta): remove this temporary api
4402 self.$$completeOutstandingRequest = completeOutstandingRequest;
4403 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
4404
4405 /**
4406 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
4407 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
4408 */
4409 function completeOutstandingRequest(fn) {
4410 try {
4411 fn.apply(null, sliceArgs(arguments, 1));
4412 } finally {
4413 outstandingRequestCount--;
4414 if (outstandingRequestCount === 0) {
4415 while(outstandingRequestCallbacks.length) {
4416 try {
4417 outstandingRequestCallbacks.pop()();
4418 } catch (e) {
4419 $log.error(e);
4420 }
4421 }
4422 }
4423 }
4424 }
4425
4426 /**
4427 * @private
4428 * Note: this method is used only by scenario runner
4429 * TODO(vojta): prefix this method with $$ ?
4430 * @param {function()} callback Function that will be called when no outstanding request
4431 */
4432 self.notifyWhenNoOutstandingRequests = function(callback) {
4433 // force browser to execute all pollFns - this is needed so that cookies and other pollers fire
4434 // at some deterministic time in respect to the test runner's actions. Leaving things up to the
4435 // regular poller would result in flaky tests.
4436 forEach(pollFns, function(pollFn){ pollFn(); });
4437
4438 if (outstandingRequestCount === 0) {
4439 callback();
4440 } else {
4441 outstandingRequestCallbacks.push(callback);
4442 }
4443 };
4444

Callers

nothing calls this directly

Calls 9

forEachFunction · 0.85
callbackFunction · 0.85
isUndefinedFunction · 0.85
startPollerFunction · 0.85
stripHashFunction · 0.85
isStringFunction · 0.85
unescapeFunction · 0.85
escapeFunction · 0.50

Tested by

no test coverage detected