This reverts commit 6910118b0d
.
Reason: this change introduces race conditions on CI.
PR Close #41707
This commit is contained in:
parent
e256d9274c
commit
baa8c70416
|
@ -103,77 +103,6 @@ describe('XMLHttpRequest', function() {
|
|||
req!.send();
|
||||
});
|
||||
|
||||
it('should run onload listeners before internal readystatechange', function(done) {
|
||||
const logs: string[] = [];
|
||||
const xhrZone = Zone.current.fork({
|
||||
name: 'xhr',
|
||||
onInvokeTask: (delegate, curr, target, task, applyThis, applyArgs) => {
|
||||
logs.push('invokeTask ' + task.source);
|
||||
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
||||
}
|
||||
});
|
||||
|
||||
xhrZone.run(function() {
|
||||
const req = new XMLHttpRequest();
|
||||
req.onload = function() {
|
||||
logs.push('onload');
|
||||
(window as any)[Zone.__symbol__('setTimeout')](() => {
|
||||
expect(logs).toEqual([
|
||||
'invokeTask XMLHttpRequest.addEventListener:load', 'onload',
|
||||
'invokeTask XMLHttpRequest.send'
|
||||
])
|
||||
done();
|
||||
});
|
||||
};
|
||||
req.open('get', '/', true);
|
||||
req.send();
|
||||
});
|
||||
});
|
||||
|
||||
it('should invoke xhr task even onload listener throw error', function(done) {
|
||||
const logs: string[] = [];
|
||||
const xhrZone = Zone.current.fork({
|
||||
name: 'xhr',
|
||||
onInvokeTask: (delegate, curr, target, task, applyThis, applyArgs) => {
|
||||
logs.push('invokeTask ' + task.source);
|
||||
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
||||
},
|
||||
onHasTask: (delegate, curr, target, hasTaskState) => {
|
||||
if (hasTaskState.change === 'macroTask') {
|
||||
logs.push('hasTask ' + hasTaskState.macroTask);
|
||||
}
|
||||
return delegate.hasTask(target, hasTaskState);
|
||||
}
|
||||
});
|
||||
|
||||
xhrZone.run(function() {
|
||||
const req = new XMLHttpRequest();
|
||||
req.onload = function() {
|
||||
logs.push('onload');
|
||||
throw new Error('test');
|
||||
};
|
||||
const unhandledRejection = (e: PromiseRejectionEvent) => {
|
||||
logs.push(e.reason.message);
|
||||
};
|
||||
window.addEventListener('unhandledrejection', unhandledRejection);
|
||||
req.addEventListener('load', () => {
|
||||
logs.push('onload1');
|
||||
(window as any)[Zone.__symbol__('setTimeout')](() => {
|
||||
expect(logs).toEqual([
|
||||
'hasTask true', 'invokeTask XMLHttpRequest.addEventListener:load', 'onload',
|
||||
'invokeTask XMLHttpRequest.addEventListener:load', 'onload1',
|
||||
'invokeTask XMLHttpRequest.send', 'hasTask false',
|
||||
'invokeTask Window.addEventListener:unhandledrejection', 'test'
|
||||
]);
|
||||
window.removeEventListener('unhandledrejection', unhandledRejection);
|
||||
done();
|
||||
});
|
||||
});
|
||||
req.open('get', '/', true);
|
||||
req.send();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return null when access ontimeout first time without error', function() {
|
||||
let req: XMLHttpRequest = new XMLHttpRequest();
|
||||
expect(req.ontimeout).toBe(null);
|
||||
|
|
Loading…
Reference in New Issue