fix(zone.js): fix zone for Jasmine 3.3. (#31497)
If zonejs is sent undefined callbacks it proceeds to attempt to call them, then fails, catches it own fail, rewrites the stack to hide the mistake, and reports a TypeError with a callstack unrelated to inputs. Throw early if the callback is undefined (as can happen if JS or any-ified TS calls zone invokeTask). Check for undefined onCommplete callback to zonejs jasmine wrapper. PR Close #31497
This commit is contained in:
parent
32aa18be78
commit
c4c340a7c4
|
@ -204,12 +204,14 @@
|
||||||
(jasmine as any).QueueRunner = (function(_super) {
|
(jasmine as any).QueueRunner = (function(_super) {
|
||||||
__extends(ZoneQueueRunner, _super);
|
__extends(ZoneQueueRunner, _super);
|
||||||
function ZoneQueueRunner(attrs: QueueRunnerAttrs) {
|
function ZoneQueueRunner(attrs: QueueRunnerAttrs) {
|
||||||
attrs.onComplete = (fn => () => {
|
if (attrs.onComplete) {
|
||||||
// All functions are done, clear the test zone.
|
attrs.onComplete = (fn => () => {
|
||||||
this.testProxyZone = null;
|
// All functions are done, clear the test zone.
|
||||||
this.testProxyZoneSpec = null;
|
this.testProxyZone = null;
|
||||||
ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
|
this.testProxyZoneSpec = null;
|
||||||
})(attrs.onComplete);
|
ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
|
||||||
|
})(attrs.onComplete);
|
||||||
|
}
|
||||||
|
|
||||||
const nativeSetTimeout = _global[Zone.__symbol__('setTimeout')];
|
const nativeSetTimeout = _global[Zone.__symbol__('setTimeout')];
|
||||||
const nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')];
|
const nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')];
|
||||||
|
|
|
@ -1217,6 +1217,9 @@ const Zone: ZoneType = (function(global: any) {
|
||||||
this.data = options;
|
this.data = options;
|
||||||
this.scheduleFn = scheduleFn;
|
this.scheduleFn = scheduleFn;
|
||||||
this.cancelFn = cancelFn;
|
this.cancelFn = cancelFn;
|
||||||
|
if (!callback) {
|
||||||
|
throw new Error('callback is not defined');
|
||||||
|
}
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
const self = this;
|
const self = this;
|
||||||
// TODO: @JiaLiPassion options should have interface
|
// TODO: @JiaLiPassion options should have interface
|
||||||
|
|
Loading…
Reference in New Issue