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

Commit d725f46

Browse files
IgorMinarbtford
authored andcommitted
fix(websockets): patch websockets via descriptors
previously when we detected that patching via descriptors is possible we would patch everything, but websockets. This change adds descriptor patching for websockets. I also fixed existing unit test which was incorrectly written. The test now correctly fails without the patch. Closes #81
1 parent 1490fb9 commit d725f46

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/patch/WebSocket.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ describe('WebSocket', function () {
1818
it('should work with addEventListener', function (done) {
1919
var parent = window.zone;
2020

21-
socket.addEventListener('message', function (contents) {
21+
socket.addEventListener('message', function (event) {
2222
expect(window.zone.parent).toBe(parent);
23-
expect(contents.data).toBe('hi');
23+
expect(event.data).toBe('hi');
2424
done();
2525
});
2626
socket.send('hi');
@@ -46,9 +46,8 @@ describe('WebSocket', function () {
4646
socket.send('hi');
4747
});
4848

49-
// TODO(vicb) this test is not working
50-
// https://github.com/angular/zone.js/issues/81
51-
xit('should work with onmessage', function (done) {
49+
50+
it('should work with onmessage', function (done) {
5251
var parent = window.zone;
5352
socket.onmessage = function (contents) {
5453
expect(window.zone.parent).toBe(parent);

zone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ Zone.canPatchViaPropertyDescriptor = function () {
452452
Zone.patchViaPropertyDescriptor = function () {
453453
Zone.patchProperties(HTMLElement.prototype, Zone.onEventNames);
454454
Zone.patchProperties(XMLHttpRequest.prototype);
455+
Zone.patchProperties(WebSocket.prototype);
455456
};
456457

457458
// Whenever any event fires, we check the event target and all parents

0 commit comments

Comments
 (0)