MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / Browser

Function Browser

code/songhop/www/lib/angular/angular.js:4865–5296  ·  view source on GitHub ↗

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

(window, document, $log, $sniffer)

Source from the content-addressed store, hash-verified

4863 * @param {object} $sniffer $sniffer service
4864 */
4865function Browser(window, document, $log, $sniffer) {
4866 var self = this,
4867 rawDocument = document[0],
4868 location = window.location,
4869 history = window.history,
4870 setTimeout = window.setTimeout,
4871 clearTimeout = window.clearTimeout,
4872 pendingDeferIds = {};
4873
4874 self.isMock = false;
4875
4876 var outstandingRequestCount = 0;
4877 var outstandingRequestCallbacks = [];
4878
4879 // TODO(vojta): remove this temporary api
4880 self.$$completeOutstandingRequest = completeOutstandingRequest;
4881 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
4882
4883 /**
4884 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
4885 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
4886 */
4887 function completeOutstandingRequest(fn) {
4888 try {
4889 fn.apply(null, sliceArgs(arguments, 1));
4890 } finally {
4891 outstandingRequestCount--;
4892 if (outstandingRequestCount === 0) {
4893 while (outstandingRequestCallbacks.length) {
4894 try {
4895 outstandingRequestCallbacks.pop()();
4896 } catch (e) {
4897 $log.error(e);
4898 }
4899 }
4900 }
4901 }
4902 }
4903
4904 function getHash(url) {
4905 var index = url.indexOf('#');
4906 return index === -1 ? '' : url.substr(index + 1);
4907 }
4908
4909 /**
4910 * @private
4911 * Note: this method is used only by scenario runner
4912 * TODO(vojta): prefix this method with $$ ?
4913 * @param {function()} callback Function that will be called when no outstanding request
4914 */
4915 self.notifyWhenNoOutstandingRequests = function(callback) {
4916 // force browser to execute all pollFns - this is needed so that cookies and other pollers fire
4917 // at some deterministic time in respect to the test runner's actions. Leaving things up to the
4918 // regular poller would result in flaky tests.
4919 forEach(pollFns, function(pollFn) { pollFn(); });
4920
4921 if (outstandingRequestCount === 0) {
4922 callback();

Callers

nothing calls this directly

Calls 10

forEachFunction · 0.70
callbackFunction · 0.70
isUndefinedFunction · 0.70
startPollerFunction · 0.70
cacheStateFunction · 0.70
stripHashFunction · 0.70
getHashFunction · 0.70
isStringFunction · 0.70
safeDecodeURIComponentFunction · 0.70

Tested by

no test coverage detected