Skip to content

Commit 86ebc5e

Browse files
committed
Make WebSocket constructor parameter "protocol" optional
In the type declarations and official spec this parameter is optional. Change-Id: Idaf35b6fa7859c0eb95b5dc998a2a6e7a7d4f4fe
1 parent 61b2806 commit 86ebc5e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/tabris/WebSocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ NativeObject.defineProperties(_WebSocket.prototype, {
3737

3838
export default class WebSocket {
3939

40-
constructor(url, protocol) {
40+
constructor(url, protocol = '') {
4141
if (typeof url !== 'string') {
4242
throw new Error(`WebSocket url ${toValueString(url)} is not a string`);
4343
}

test/tabris/WebSocket.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ describe('WebSocket', function() {
2424
expect(WebSocket).to.be.a('function');
2525
});
2626

27-
it('declares 2 formal parameters', function() {
28-
expect(WebSocket.length).to.equal(2);
29-
});
30-
3127
it('fails when url parameter is omitted', function() {
3228
expect(() => new WebSocket())
3329
.to.throw('WebSocket url undefined is not a string');
@@ -43,9 +39,8 @@ describe('WebSocket', function() {
4339
.to.throw('WebSocket url has to have a scheme of \'ws\' or \'wss\' but is \'http\'');
4440
});
4541

46-
it('fails when protocol is omitted', function() {
47-
expect(() => new WebSocket('ws://url.com'))
48-
.to.throw('WebSocket protocol has too be a string or an array of strings');
42+
it('accepts missing protocol', function() {
43+
expect(() => new WebSocket('ws://url.com')).not.to.throw(Error);
4944
});
5045

5146
it('fails when protocol is not string', function() {

0 commit comments

Comments
 (0)