Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misuse of SyntaxError #1355

Closed
rwaldron opened this issue Jun 7, 2017 · 2 comments · Fixed by #1356
Closed

Misuse of SyntaxError #1355

rwaldron opened this issue Jun 7, 2017 · 2 comments · Fixed by #1356

Comments

@rwaldron
Copy link

rwaldron commented Jun 7, 2017

In step 8 of https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createdatachannel:

  1. If both the maxPacketLifeTime and maxRetransmits attributes are set (not null), throw a SyntaxError.

This error must not be a SyntaxError, which defined as:

19.5.5.4SyntaxError
Indicates that a parsing error has occurred.

The correct error to use is TypeError. Given the same case, applied to descriptor properties:

Object.defineProperty({}, "foo", {
  get() {
    return 1;
  },
  writable: false
});

Will have such results as:

  • Firefox
    TypeError: property descriptors must not specify a value or be writable when a getter 
    or setter has been specified
    
  • Chrome
    Uncaught TypeError: Invalid property descriptor. Cannot both specify accessors and a 
    value or writable attribute, #<Object>
    
  • Safari
    TypeError: Invalid property.  'writable' present on property with getter or setter.
    

I recommend throwing a TypeError with message "Invalid options, maxPacketLifeTime and maxRetransmits cannot both be null" (or something similar)

@adam-be
Copy link
Member

adam-be commented Jun 8, 2017

I think this makes sense. Created PR (#1356).

@rwaldron
Copy link
Author

rwaldron commented Jun 8, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants