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

Commit

Permalink
fix(websockets): patch websockets via descriptors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
IgorMinar authored and btford committed May 1, 2015
1 parent 1490fb9 commit d725f46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/patch/WebSocket.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('WebSocket', function () {
it('should work with addEventListener', function (done) {
var parent = window.zone;

socket.addEventListener('message', function (contents) {
socket.addEventListener('message', function (event) {
expect(window.zone.parent).toBe(parent);
expect(contents.data).toBe('hi');
expect(event.data).toBe('hi');
done();
});
socket.send('hi');
Expand All @@ -46,9 +46,8 @@ describe('WebSocket', function () {
socket.send('hi');
});

// TODO(vicb) this test is not working
// https://github.com/angular/zone.js/issues/81
xit('should work with onmessage', function (done) {

it('should work with onmessage', function (done) {
var parent = window.zone;
socket.onmessage = function (contents) {
expect(window.zone.parent).toBe(parent);
Expand Down
1 change: 1 addition & 0 deletions zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ Zone.canPatchViaPropertyDescriptor = function () {
Zone.patchViaPropertyDescriptor = function () {
Zone.patchProperties(HTMLElement.prototype, Zone.onEventNames);
Zone.patchProperties(XMLHttpRequest.prototype);
Zone.patchProperties(WebSocket.prototype);
};

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

0 comments on commit d725f46

Please sign in to comment.