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

Commit 554fae0

Browse files
committedMay 18, 2015
feat(zone.js): support IE9+
1 parent 8f262aa commit 554fae0

8 files changed

+55
-26
lines changed
 

‎dist/long-stack-trace-zone.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Zone.Stacktrace = function (e) {
88
this._e = e;
99
};
1010
Zone.Stacktrace.prototype.get = function () {
11-
if (zone.stackFramesFilter) {
11+
if (zone.stackFramesFilter && this._e.stack) {
1212
return this._e.stack.
1313
split('\n').
1414
filter(zone.stackFramesFilter).
@@ -47,7 +47,7 @@ Zone.longStackTraceZone = {
4747
var trace = [];
4848
var zone = this;
4949
if (exception) {
50-
if (zone.stackFramesFilter) {
50+
if (zone.stackFramesFilter && exception.stack) {
5151
trace.push(exception.stack.split('\n').
5252
filter(zone.stackFramesFilter).
5353
join('\n'));

‎lib/patch/event-target.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function apply() {
2727
'Window',
2828
'Worker',
2929
'WorkerGlobalScope',
30+
'XMLHttpRequest',
3031
'XMLHttpRequestEventTarget',
3132
'XMLHttpRequestUpload'
3233
];

‎lib/patch/property-descriptor.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ function apply() {
1313
});
1414
utils.patchProperties(HTMLElement.prototype, onEventNames);
1515
utils.patchProperties(XMLHttpRequest.prototype);
16-
utils.patchProperties(WebSocket.prototype);
16+
if (typeof WebSocket !== 'undefined') {
17+
utils.patchProperties(WebSocket.prototype);
18+
}
1719
} else {
1820
// Safari
1921
patchViaCapturingAllTheEvents();

‎sauce.conf.js

+18
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ module.exports = function (config) {
3131
browserName: 'safari',
3232
platform: 'OS X 10.10',
3333
version: '8'
34+
},
35+
'SL_IE_9': {
36+
base: 'SauceLabs',
37+
browserName: 'internet explorer',
38+
platform: 'Windows 2008',
39+
version: '9'
40+
},
41+
'SL_IE_10': {
42+
base: 'SauceLabs',
43+
browserName: 'internet explorer',
44+
platform: 'Windows 2012',
45+
version: '10'
46+
},
47+
'SL_IE_11': {
48+
base: 'SauceLabs',
49+
browserName: 'internet explorer',
50+
platform: 'Windows 8.1',
51+
version: '11'
3452
}
3553
};
3654

‎test/microtasks.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Microtasks', function () {
1717
setTimeout(function() {
1818
expect(log).toEqual([1, 2, 3]);
1919
done();
20-
}, 0);
20+
}, 10);
2121
});
2222

2323
it('should correctly schedule microtasks vs macrotasks', function(done) {
@@ -33,19 +33,19 @@ describe('Microtasks', function () {
3333
log.push('mat1.mit');
3434
});
3535
log.push('-mat1');
36-
}, 0);
36+
}, 10);
3737

3838
setTimeout(function() {
3939
log.push('mat2');
40-
}, 0);
40+
}, 20);
4141

4242
setTimeout(function() {
4343
expect(log).toEqual([
4444
'+root', '-root', 'root.mit',
4545
'+mat1', '-mat1', 'mat1.mit',
4646
'mat2']);
4747
done();
48-
}, 0);
48+
}, 30);
4949

5050
log.push('-root');
5151
});

‎test/patch/WebSocket.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
describe('WebSocket', function () {
3+
describe('WebSocket', ifEnvSupports('WebSocket', function () {
44
var socket;
55
var TEST_SERVER_URL = 'ws://localhost:8001';
66
var flag;
@@ -104,4 +104,4 @@ describe('WebSocket', function () {
104104
done();
105105
}, 500);
106106
});
107-
});
107+
}));

‎test/patch/XMLHttpRequest.spec.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ describe('XMLHttpRequest', function () {
2121
req.send();
2222
});
2323

24-
it('should work with onprogress', function (done) {
25-
var req;
26-
27-
testZone.run(function() {
28-
req = new XMLHttpRequest();
29-
req.onprogress = function () {
30-
// Make sure that the callback will only be called once
31-
req.onprogress = null;
32-
expect(window.zone).toBeDirectChildOf(testZone);
33-
done();
34-
};
35-
req.open('get', '/', true);
24+
var supportsOnProgress = function() {
25+
return 'onprogress' in new XMLHttpRequest();
26+
}
27+
supportsOnProgress.message = "XMLHttpRequest.onprogress";
28+
29+
describe('onprogress', ifEnvSupports(supportsOnProgress, function () {
30+
it('should work with onprogress', function (done) {
31+
var req;
32+
testZone.run(function() {
33+
req = new XMLHttpRequest();
34+
req.onprogress = function () {
35+
// Make sure that the callback will only be called once
36+
req.onprogress = null;
37+
expect(window.zone).toBeDirectChildOf(testZone);
38+
done();
39+
};
40+
req.open('get', '/', true);
41+
});
42+
43+
req.send();
3644
});
37-
38-
req.send();
39-
});
45+
}));
4046

4147
it('should preserve other setters', function () {
4248
var req = new XMLHttpRequest();
@@ -47,3 +53,4 @@ describe('XMLHttpRequest', function () {
4753
});
4854

4955
});
56+

‎test/patch/element.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe('element', function () {
1212

1313
afterEach(function () {
1414
document.body.removeChild(button);
15-
button.remove();
1615
});
1716

1817
it('should work with addEventListener', function () {
@@ -35,7 +34,9 @@ describe('element', function () {
3534
button.addEventListener('focus', logFunction);
3635
button.click();
3736
expect(log).toEqual('a');
38-
button.dispatchEvent(new Event('focus'));
37+
var focusEvent = document.createEvent('Event');
38+
focusEvent.initEvent('focus', true, true)
39+
button.dispatchEvent(focusEvent);
3940
expect(log).toEqual('aa');
4041

4142
button.removeEventListener('click', logFunction);

0 commit comments

Comments
 (0)
This repository has been archived.