[webrtc-pc] Misuse of SyntaxError

rwaldron has just created a new issue for https://github.com/w3c/webrtc-pc:

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


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

This error must not be a SyntaxError, [which defined as](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror):

> 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: 

```js
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)

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1355 using your GitHub account

Received on Wednesday, 7 June 2017 18:17:11 UTC