MCPcopy Create free account
hub / github.com/apache/cloudstack / Browser

Function Browser

tools/ngui/static/js/lib/angular.js:3017–3354  ·  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

3015 * @param {object} $sniffer $sniffer service
3016 */
3017function Browser(window, document, $log, $sniffer) {
3018 var self = this,
3019 rawDocument = document[0],
3020 location = window.location,
3021 history = window.history,
3022 setTimeout = window.setTimeout,
3023 clearTimeout = window.clearTimeout,
3024 pendingDeferIds = {};
3025
3026 self.isMock = false;
3027
3028 var outstandingRequestCount = 0;
3029 var outstandingRequestCallbacks = [];
3030
3031 // TODO(vojta): remove this temporary api
3032 self.$$completeOutstandingRequest = completeOutstandingRequest;
3033 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
3034
3035 /**
3036 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
3037 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
3038 */
3039 function completeOutstandingRequest(fn) {
3040 try {
3041 fn.apply(null, sliceArgs(arguments, 1));
3042 } finally {
3043 outstandingRequestCount--;
3044 if (outstandingRequestCount === 0) {
3045 while(outstandingRequestCallbacks.length) {
3046 try {
3047 outstandingRequestCallbacks.pop()();
3048 } catch (e) {
3049 $log.error(e);
3050 }
3051 }
3052 }
3053 }
3054 }
3055
3056 /**
3057 * @private
3058 * Note: this method is used only by scenario runner
3059 * TODO(vojta): prefix this method with $$ ?
3060 * @param {function()} callback Function that will be called when no outstanding request
3061 */
3062 self.notifyWhenNoOutstandingRequests = function(callback) {
3063 // force browser to execute all pollFns - this is needed so that cookies and other pollers fire
3064 // at some deterministic time in respect to the test runner's actions. Leaving things up to the
3065 // regular poller would result in flaky tests.
3066 forEach(pollFns, function(pollFn){ pollFn(); });
3067
3068 if (outstandingRequestCount === 0) {
3069 callback();
3070 } else {
3071 outstandingRequestCallbacks.push(callback);
3072 }
3073 };
3074

Callers

nothing calls this directly

Calls 7

forEachFunction · 0.85
isUndefinedFunction · 0.85
startPollerFunction · 0.85
isStringFunction · 0.85
replaceMethod · 0.80
findMethod · 0.65

Tested by

no test coverage detected