This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 16999 - Clarify JS type for empty close reason
Summary: Clarify JS type for empty close reason
Status: RESOLVED INVALID
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebSocket API (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P2 minor
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-08 19:31 UTC by Jason Duell
Modified: 2012-05-10 07:22 UTC (History)
4 users (show)

See Also:


Attachments

Description Jason Duell 2012-05-08 19:31:00 UTC
I don't believe the Web socket spec is clear on this:

If there is no close 'reason' passed from the server in the protocol (which on a network frame level is different than sending an empty Unicode string), should we set the close event's 'reason' field to 'undefined', or to an empty string?   Right now Firefox is setting it to an empty string.  Logically, I feel it ought to be 'undefined'.  But I don't see much harm in it being an empty string.  Either way the spec should be clear about it.
Comment 1 Jonas Sicking (Not reading bugmail) 2012-05-08 21:04:09 UTC
Rather than undefined I think null would be more appropriate. But I'd be ok either way.
Comment 2 Ms2ger 2012-05-09 17:07:31 UTC
> The reason attribute must return the value it was initialized to.
> When the object is created, this attribute must be initialized to
> empty string.

What's unclear? (Except for the missing 'the')
Comment 3 Jason Duell 2012-05-09 20:59:12 UTC
> attribute must be initialized to empty string.

Ah, didn't see that.  So the spec is clear then--'reason' will never be null/undefined.
Comment 4 Simon Pieters 2012-05-10 07:22:43 UTC
I think this is the relevant part

"whose reason attribute is initialized to the WebSocket connection close reason decoded as UTF-8, with error handling, and dispatch the event at the WebSocket object. [WSP]"

and then WSP says

"If there is no such data in the Close control frame, _The WebSocket Connection Close Reason_ is the empty string."

But the result is the same. :-)