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

Commit

Permalink
feat(zone.js): support IE9+
Browse files Browse the repository at this point in the history
  • Loading branch information
marclaval committed May 18, 2015
1 parent 8f262aa commit 554fae0
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 26 deletions.
4 changes: 2 additions & 2 deletions dist/long-stack-trace-zone.js
Expand Up @@ -8,7 +8,7 @@ Zone.Stacktrace = function (e) {
this._e = e;
};
Zone.Stacktrace.prototype.get = function () {
if (zone.stackFramesFilter) {
if (zone.stackFramesFilter && this._e.stack) {
return this._e.stack.
split('\n').
filter(zone.stackFramesFilter).
Expand Down Expand Up @@ -47,7 +47,7 @@ Zone.longStackTraceZone = {
var trace = [];
var zone = this;
if (exception) {
if (zone.stackFramesFilter) {
if (zone.stackFramesFilter && exception.stack) {
trace.push(exception.stack.split('\n').
filter(zone.stackFramesFilter).
join('\n'));
Expand Down
1 change: 1 addition & 0 deletions lib/patch/event-target.js
Expand Up @@ -27,6 +27,7 @@ function apply() {
'Window',
'Worker',
'WorkerGlobalScope',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload'
];
Expand Down
4 changes: 3 additions & 1 deletion lib/patch/property-descriptor.js
Expand Up @@ -13,7 +13,9 @@ function apply() {
});
utils.patchProperties(HTMLElement.prototype, onEventNames);
utils.patchProperties(XMLHttpRequest.prototype);
utils.patchProperties(WebSocket.prototype);
if (typeof WebSocket !== 'undefined') {
utils.patchProperties(WebSocket.prototype);
}
} else {
// Safari
patchViaCapturingAllTheEvents();
Expand Down
18 changes: 18 additions & 0 deletions sauce.conf.js
Expand Up @@ -31,6 +31,24 @@ module.exports = function (config) {
browserName: 'safari',
platform: 'OS X 10.10',
version: '8'
},
'SL_IE_9': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 2008',
version: '9'
},
'SL_IE_10': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 2012',
version: '10'
},
'SL_IE_11': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
}
};

Expand Down
8 changes: 4 additions & 4 deletions test/microtasks.spec.js
Expand Up @@ -17,7 +17,7 @@ describe('Microtasks', function () {
setTimeout(function() {
expect(log).toEqual([1, 2, 3]);
done();
}, 0);
}, 10);
});

it('should correctly schedule microtasks vs macrotasks', function(done) {
Expand All @@ -33,19 +33,19 @@ describe('Microtasks', function () {
log.push('mat1.mit');
});
log.push('-mat1');
}, 0);
}, 10);

setTimeout(function() {
log.push('mat2');
}, 0);
}, 20);

setTimeout(function() {
expect(log).toEqual([
'+root', '-root', 'root.mit',
'+mat1', '-mat1', 'mat1.mit',
'mat2']);
done();
}, 0);
}, 30);

log.push('-root');
});
Expand Down
4 changes: 2 additions & 2 deletions test/patch/WebSocket.spec.js
@@ -1,6 +1,6 @@
'use strict';

describe('WebSocket', function () {
describe('WebSocket', ifEnvSupports('WebSocket', function () {
var socket;
var TEST_SERVER_URL = 'ws://localhost:8001';
var flag;
Expand Down Expand Up @@ -104,4 +104,4 @@ describe('WebSocket', function () {
done();
}, 500);
});
});
}));
37 changes: 22 additions & 15 deletions test/patch/XMLHttpRequest.spec.js
Expand Up @@ -21,22 +21,28 @@ describe('XMLHttpRequest', function () {
req.send();
});

it('should work with onprogress', function (done) {
var req;

testZone.run(function() {
req = new XMLHttpRequest();
req.onprogress = function () {
// Make sure that the callback will only be called once
req.onprogress = null;
expect(window.zone).toBeDirectChildOf(testZone);
done();
};
req.open('get', '/', true);
var supportsOnProgress = function() {
return 'onprogress' in new XMLHttpRequest();
}
supportsOnProgress.message = "XMLHttpRequest.onprogress";

describe('onprogress', ifEnvSupports(supportsOnProgress, function () {
it('should work with onprogress', function (done) {
var req;
testZone.run(function() {
req = new XMLHttpRequest();
req.onprogress = function () {
// Make sure that the callback will only be called once
req.onprogress = null;
expect(window.zone).toBeDirectChildOf(testZone);
done();
};
req.open('get', '/', true);
});

req.send();
});

req.send();
});
}));

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

});

5 changes: 3 additions & 2 deletions test/patch/element.spec.js
Expand Up @@ -12,7 +12,6 @@ describe('element', function () {

afterEach(function () {
document.body.removeChild(button);
button.remove();
});

it('should work with addEventListener', function () {
Expand All @@ -35,7 +34,9 @@ describe('element', function () {
button.addEventListener('focus', logFunction);
button.click();
expect(log).toEqual('a');
button.dispatchEvent(new Event('focus'));
var focusEvent = document.createEvent('Event');
focusEvent.initEvent('focus', true, true)
button.dispatchEvent(focusEvent);
expect(log).toEqual('aa');

button.removeEventListener('click', logFunction);
Expand Down

0 comments on commit 554fae0

Please sign in to comment.