MCPcopy Index your code
hub / github.com/angular/angular / ZoneQueueRunner

Function ZoneQueueRunner

packages/zone.js/lib/jasmine/jasmine.ts:252–311  ·  view source on GitHub ↗
(this: QueueRunner, attrs: QueueRunnerAttrs)

Source from the content-addressed store, hash-verified

250 privateApis.QueueRunner = (function (_super) {
251 __extends(ZoneQueueRunner, _super);
252 function ZoneQueueRunner(this: QueueRunner, attrs: QueueRunnerAttrs) {
253 if (attrs.onComplete) {
254 attrs.onComplete = ((fn) => () => {
255 // All functions are done, clear the test zone.
256 this.testProxyZone = null;
257 this.testProxyZoneSpec = null;
258 ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
259 })(attrs.onComplete);
260 }
261
262 const nativeSetTimeout = global[Zone.__symbol__('setTimeout')];
263 const nativeClearTimeout = global[Zone.__symbol__('clearTimeout')];
264 if (nativeSetTimeout) {
265 // should run setTimeout inside jasmine outside of zone
266 attrs.timeout = {
267 setTimeout: nativeSetTimeout ? nativeSetTimeout : global.setTimeout,
268 clearTimeout: nativeClearTimeout ? nativeClearTimeout : global.clearTimeout,
269 };
270 }
271
272 // create a userContext to hold the queueRunner itself
273 // so we can access the testProxy in it/xit/beforeEach ...
274 if (privateApis.UserContext) {
275 if (!attrs.userContext) {
276 attrs.userContext = new privateApis.UserContext();
277 }
278 attrs.userContext.queueRunner = this;
279 } else {
280 if (!attrs.userContext) {
281 attrs.userContext = {};
282 }
283 attrs.userContext.queueRunner = this;
284 }
285
286 // patch attrs.onException
287 const onException = attrs.onException;
288 attrs.onException = function (this: undefined | QueueRunner, error: any) {
289 if (
290 error &&
291 error.message ===
292 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'
293 ) {
294 // jasmine timeout, we can make the error message more
295 // reasonable to tell what tasks are pending
296 const proxyZoneSpec: any = this && this.testProxyZoneSpec;
297 if (proxyZoneSpec) {
298 const pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo();
299 try {
300 // try catch here in case error.message is not writable
301 error.message += pendingTasksInfo;
302 } catch (err) {}
303 }
304 }
305 if (onException) {
306 onException.call(this, error);
307 }
308 };
309

Callers

nothing calls this directly

Calls 3

__symbol__Method · 0.80
scheduleMicroTaskMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…