Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6654b69

Browse files
committed
chore: release v0.8.21
1 parent 68682cd commit 6654b69

28 files changed

+2414
-401
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
<a name="0.8.21"></a>
2+
## [0.8.21](https://github.com/angular/zone.js/compare/v0.8.20...0.8.21) (2018-03-30)
3+
4+
5+
### Bug Fixes
6+
7+
* add OriginalDelegate prop to Function::toString ([#993](https://github.com/angular/zone.js/issues/993)) ([2dc7e5c](https://github.com/angular/zone.js/commit/2dc7e5c))
8+
* **core:** fix [#1000](https://github.com/angular/zone.js/issues/1000), check target is null or not when patchOnProperty ([#1004](https://github.com/angular/zone.js/issues/1004)) ([5c139e5](https://github.com/angular/zone.js/commit/5c139e5))
9+
* **core:** fix [#946](https://github.com/angular/zone.js/issues/946), don't patch promise if it is not writable ([#1041](https://github.com/angular/zone.js/issues/1041)) ([c8c5990](https://github.com/angular/zone.js/commit/c8c5990))
10+
* **event:** fix [#1021](https://github.com/angular/zone.js/issues/1021), removeListener/removeAllListeners should return eventEmitter ([#1022](https://github.com/angular/zone.js/issues/1022)) ([ab72df6](https://github.com/angular/zone.js/commit/ab72df6))
11+
* **fakeAsync:** fix [#1056](https://github.com/angular/zone.js/issues/1056), fakeAsync timerId should not be zero ([#1057](https://github.com/angular/zone.js/issues/1057)) ([68682cd](https://github.com/angular/zone.js/commit/68682cd))
12+
* **jasmine:** fix [#1015](https://github.com/angular/zone.js/issues/1015), make jasmine patch compatible to jasmine 3.x ([#1016](https://github.com/angular/zone.js/issues/1016)) ([e1df4bc](https://github.com/angular/zone.js/commit/e1df4bc))
13+
* **patch:** fix [#998](https://github.com/angular/zone.js/issues/998), patch mediaQuery for new Safari ([#1003](https://github.com/angular/zone.js/issues/1003)) ([c7c7db5](https://github.com/angular/zone.js/commit/c7c7db5))
14+
* **proxy:** proxyZone should call onHasTask when change delegate ([#1030](https://github.com/angular/zone.js/issues/1030)) ([40b110d](https://github.com/angular/zone.js/commit/40b110d))
15+
* **test:** fix mocha compatible issue ([#1028](https://github.com/angular/zone.js/issues/1028)) ([c554e9f](https://github.com/angular/zone.js/commit/c554e9f))
16+
* **testing:** fix [#1032](https://github.com/angular/zone.js/issues/1032), fakeAsync should pass parameters correctly ([#1033](https://github.com/angular/zone.js/issues/1033)) ([eefe983](https://github.com/angular/zone.js/commit/eefe983))
17+
18+
19+
### Features
20+
21+
* **bluebird:** fix [#921](https://github.com/angular/zone.js/issues/921), [#977](https://github.com/angular/zone.js/issues/977), support bluebird ([#1039](https://github.com/angular/zone.js/issues/1039)) ([438210c](https://github.com/angular/zone.js/commit/438210c))
22+
* **build:** use yarn instead of npm ([#1025](https://github.com/angular/zone.js/issues/1025)) ([ebd348c](https://github.com/angular/zone.js/commit/ebd348c))
23+
* **core:** fix [#996](https://github.com/angular/zone.js/issues/996), expose UncaughtPromiseError ([#1040](https://github.com/angular/zone.js/issues/1040)) ([7f178b1](https://github.com/angular/zone.js/commit/7f178b1))
24+
* **jasmine:** support Date.now in fakeAsyncTest ([#1009](https://github.com/angular/zone.js/issues/1009)) ([f22065e](https://github.com/angular/zone.js/commit/f22065e))
25+
* **jsonp:** provide a help method to patch jsonp ([#997](https://github.com/angular/zone.js/issues/997)) ([008fd43](https://github.com/angular/zone.js/commit/008fd43))
26+
* **patch:** fix [#1011](https://github.com/angular/zone.js/issues/1011), patch ResizeObserver ([#1012](https://github.com/angular/zone.js/issues/1012)) ([8ee88da](https://github.com/angular/zone.js/commit/8ee88da))
27+
* **patch:** fix [#828](https://github.com/angular/zone.js/issues/828), patch socket.io client ([b3db9f4](https://github.com/angular/zone.js/commit/b3db9f4))
28+
* **promise:** support Promise.prototype.finally ([#1005](https://github.com/angular/zone.js/issues/1005)) ([6a1a830](https://github.com/angular/zone.js/commit/6a1a830))
29+
* **rollup:** use new rollup config to prevent warning ([#1006](https://github.com/angular/zone.js/issues/1006)) ([6b6b38a](https://github.com/angular/zone.js/commit/6b6b38a))
30+
* **test:** can handle non zone aware task in promise ([#1014](https://github.com/angular/zone.js/issues/1014)) ([6852f1d](https://github.com/angular/zone.js/commit/6852f1d))
31+
* **test:** move async/fakeAsync from angular to zone.js ([#1048](https://github.com/angular/zone.js/issues/1048)) ([a4b42cd](https://github.com/angular/zone.js/commit/a4b42cd))
32+
* **testing:** can display pending tasks info when test timeout in jasmine/mocha ([#1038](https://github.com/angular/zone.js/issues/1038)) ([57bc80c](https://github.com/angular/zone.js/commit/57bc80c))
33+
34+
35+
136
<a name="0.8.20"></a>
237
## [0.8.20](https://github.com/angular/zone.js/compare/v0.8.19...0.8.20) (2018-01-10)
338

dist/async-test.js

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,95 @@
1818
* Use of this source code is governed by an MIT-style license that can be
1919
* found in the LICENSE file at https://angular.io/license
2020
*/
21-
var AsyncTestZoneSpec = (function () {
21+
var AsyncTestZoneSpec = /** @class */ (function () {
2222
function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {
23+
this.finishCallback = finishCallback;
24+
this.failCallback = failCallback;
2325
this._pendingMicroTasks = false;
2426
this._pendingMacroTasks = false;
2527
this._alreadyErrored = false;
28+
this._isSync = false;
2629
this.runZone = Zone.current;
27-
this._finishCallback = finishCallback;
28-
this._failCallback = failCallback;
30+
this.unresolvedChainedPromiseCount = 0;
2931
this.name = 'asyncTestZone for ' + namePrefix;
32+
this.properties = {
33+
'AsyncTestZoneSpec': this
34+
};
3035
}
3136
AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () {
3237
var _this = this;
33-
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) {
38+
if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) {
3439
// We do this because we would like to catch unhandled rejected promises.
3540
this.runZone.run(function () {
3641
setTimeout(function () {
3742
if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) {
38-
_this._finishCallback();
43+
_this.finishCallback();
3944
}
4045
}, 0);
4146
});
4247
}
4348
};
49+
AsyncTestZoneSpec.prototype.patchPromiseForTest = function () {
50+
var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')];
51+
if (patchPromiseForTest) {
52+
patchPromiseForTest();
53+
}
54+
};
55+
AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () {
56+
var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')];
57+
if (unPatchPromiseForTest) {
58+
unPatchPromiseForTest();
59+
}
60+
};
61+
AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) {
62+
if (task.type !== 'eventTask') {
63+
this._isSync = false;
64+
}
65+
if (task.type === 'microTask' && task.data && task.data instanceof Promise) {
66+
// check whether the promise is a chained promise
67+
if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) {
68+
// chained promise is being scheduled
69+
this.unresolvedChainedPromiseCount--;
70+
}
71+
}
72+
return delegate.scheduleTask(target, task);
73+
};
74+
AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) {
75+
if (task.type !== 'eventTask') {
76+
this._isSync = false;
77+
}
78+
return delegate.invokeTask(target, task, applyThis, applyArgs);
79+
};
80+
AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) {
81+
if (task.type !== 'eventTask') {
82+
this._isSync = false;
83+
}
84+
return delegate.cancelTask(target, task);
85+
};
4486
// Note - we need to use onInvoke at the moment to call finish when a test is
4587
// fully synchronous. TODO(juliemr): remove this when the logic for
4688
// onHasTask changes and it calls whenever the task queues are dirty.
89+
// updated by(JiaLiPassion), only call finish callback when no task
90+
// was scheduled/invoked/canceled.
4791
AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
4892
try {
93+
this.patchPromiseForTest();
94+
this._isSync = true;
4995
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
5096
}
5197
finally {
52-
this._finishCallbackIfDone();
98+
this.unPatchPromiseForTest();
99+
var afterTaskCounts = parentZoneDelegate._taskCounts;
100+
if (this._isSync) {
101+
this._finishCallbackIfDone();
102+
}
53103
}
54104
};
55105
AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
56106
// Let the parent try to handle the error.
57107
var result = parentZoneDelegate.handleError(targetZone, error);
58108
if (result) {
59-
this._failCallback(error);
109+
this.failCallback(error);
60110
this._alreadyErrored = true;
61111
}
62112
return false;
@@ -72,6 +122,7 @@ var AsyncTestZoneSpec = (function () {
72122
this._finishCallbackIfDone();
73123
}
74124
};
125+
AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved');
75126
return AsyncTestZoneSpec;
76127
}());
77128
// Export the class so that new instances can be created with proper

dist/fake-async-test.js

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,48 @@
1919
* found in the LICENSE file at https://angular.io/license
2020
*/
2121
(function (global) {
22-
var Scheduler = (function () {
22+
var OriginalDate = global.Date;
23+
var FakeDate = /** @class */ (function () {
24+
function FakeDate() {
25+
var d = new OriginalDate();
26+
d.setTime(global.Date.now());
27+
return d;
28+
}
29+
FakeDate.UTC = function () {
30+
return OriginalDate.UTC();
31+
};
32+
FakeDate.now = function () {
33+
var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
34+
if (fakeAsyncTestZoneSpec) {
35+
return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime();
36+
}
37+
return OriginalDate.now.apply(this, arguments);
38+
};
39+
FakeDate.parse = function () {
40+
return OriginalDate.parse();
41+
};
42+
return FakeDate;
43+
}());
44+
var Scheduler = /** @class */ (function () {
2345
function Scheduler() {
2446
// Next scheduler id.
25-
this.nextId = 0;
47+
this.nextId = 1;
2648
// Scheduler queue with the tuple of end time and callback function - sorted by end time.
2749
this._schedulerQueue = [];
2850
// Current simulated time in millis.
2951
this._currentTime = 0;
52+
// Current real time in millis.
53+
this._currentRealTime = Date.now();
3054
}
55+
Scheduler.prototype.getCurrentTime = function () {
56+
return this._currentTime;
57+
};
58+
Scheduler.prototype.getCurrentRealTime = function () {
59+
return this._currentRealTime;
60+
};
61+
Scheduler.prototype.setCurrentRealTime = function (realTime) {
62+
this._currentRealTime = realTime;
63+
};
3164
Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) {
3265
if (args === void 0) { args = []; }
3366
if (isPeriodic === void 0) { isPeriodic = false; }
@@ -148,7 +181,7 @@
148181
};
149182
return Scheduler;
150183
}());
151-
var FakeAsyncTestZoneSpec = (function () {
184+
var FakeAsyncTestZoneSpec = /** @class */ (function () {
152185
function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) {
153186
if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; }
154187
this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame;
@@ -238,11 +271,7 @@
238271
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id);
239272
this._scheduler.removeScheduledFunctionWithId(id);
240273
};
241-
FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) {
242-
var args = [];
243-
for (var _i = 2; _i < arguments.length; _i++) {
244-
args[_i - 2] = arguments[_i];
245-
}
274+
FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) {
246275
var id = this._scheduler.nextId;
247276
var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) };
248277
var cb = this._fnAndFlush(fn, completers);
@@ -263,6 +292,27 @@
263292
this._lastError = null;
264293
throw error;
265294
};
295+
FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () {
296+
return this._scheduler.getCurrentTime();
297+
};
298+
FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () {
299+
return this._scheduler.getCurrentRealTime();
300+
};
301+
FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) {
302+
this._scheduler.setCurrentRealTime(realTime);
303+
};
304+
FakeAsyncTestZoneSpec.patchDate = function () {
305+
if (global['Date'] === FakeDate) {
306+
// already patched
307+
return;
308+
}
309+
global['Date'] = FakeDate;
310+
};
311+
FakeAsyncTestZoneSpec.resetDate = function () {
312+
if (global['Date'] === FakeDate) {
313+
global['Date'] = OriginalDate;
314+
}
315+
};
266316
FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) {
267317
if (millis === void 0) { millis = 0; }
268318
FakeAsyncTestZoneSpec.assertInZone();
@@ -319,12 +369,10 @@
319369
case 'macroTask':
320370
switch (task.source) {
321371
case 'setTimeout':
322-
task.data['handleId'] =
323-
this._setTimeout(task.invoke, task.data['delay'], task.data['args']);
372+
task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2));
324373
break;
325374
case 'setInterval':
326-
task.data['handleId'] =
327-
this._setInterval(task.invoke, task.data['delay'], task.data['args']);
375+
task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2));
328376
break;
329377
case 'XMLHttpRequest.send':
330378
throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' +
@@ -385,6 +433,15 @@
385433
return delegate.cancelTask(target, task);
386434
}
387435
};
436+
FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) {
437+
try {
438+
FakeAsyncTestZoneSpec.patchDate();
439+
return delegate.invoke(target, callback, applyThis, applyArgs, source);
440+
}
441+
finally {
442+
FakeAsyncTestZoneSpec.resetDate();
443+
}
444+
};
388445
FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) {
389446
if (!this.macroTaskOptions) {
390447
return null;

0 commit comments

Comments
 (0)