Bug 164057 - WebRTC: RTCPeerConnection constructor argument should be optional
Summary: WebRTC: RTCPeerConnection constructor argument should be optional
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nael Ouedraogo
URL:
Keywords:
Depends on:
Blocks: 158936
  Show dependency treegraph
 
Reported: 2016-10-27 03:21 PDT by Nael Ouedraogo
Modified: 2016-12-20 02:25 PST (History)
3 users (show)

See Also:


Attachments
Patch (5.33 KB, patch)
2016-10-27 03:35 PDT, Nael Ouedraogo
no flags Details | Formatted Diff | Diff
Patch (8.19 KB, patch)
2016-12-19 07:06 PST, Nael Ouedraogo
no flags Details | Formatted Diff | Diff
Patch (8.13 KB, patch)
2016-12-19 10:04 PST, Nael Ouedraogo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nael Ouedraogo 2016-10-27 03:21:45 PDT
RTCPeerConnection constructor argument should be optional.
Comment 1 Nael Ouedraogo 2016-10-27 03:35:34 PDT
Created attachment 293010 [details]
Patch
Comment 2 youenn fablet 2016-10-27 05:04:24 PDT
Comment on attachment 293010 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=293010&action=review

> Source/WebCore/Modules/mediastream/RTCPeerConnection.js:43
> +            this.@initializeWith(configuration);

I think we may need to call @initializeWith even if configuration is undefined.
In that case, we might need to pass an empty dictionary.
Or we could pass a dictionary with the default values if we want to handle defaults here.
Probably simpler to just pass an empty object.
Comment 3 youenn fablet 2016-10-27 05:10:36 PDT
Also, some of the newly imported tests in LayoutTests/imported/w3c/web-platform-tests/webrtc might cover these changes.
Might want to activate some of them
Comment 4 youenn fablet 2016-10-27 05:24:19 PDT
(In reply to comment #2)
> Comment on attachment 293010 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=293010&action=review
> 
> > Source/WebCore/Modules/mediastream/RTCPeerConnection.js:43
> > +            this.@initializeWith(configuration);
> 
> I think we may need to call @initializeWith even if configuration is
> undefined.
> In that case, we might need to pass an empty dictionary.
> Or we could pass a dictionary with the default values if we want to handle
> defaults here.
> Probably simpler to just pass an empty object.

If we do not need to call @initializeWith, it might be best to rename this function to something like @setConfiguration.
Comment 5 Adam Bergkvist 2016-10-27 06:38:37 PDT
(A side note.) A lot of tests have a dummy configuration used to construct RTCPeerConnection since the argument wasn't optional. We might want to clean that up.
Comment 6 youenn fablet 2016-10-27 06:47:13 PDT
(In reply to comment #5)
> (A side note.) A lot of tests have a dummy configuration used to construct
> RTCPeerConnection since the argument wasn't optional. We might want to clean
> that up.

OK, it might be safer then to make the call to @initializeWith mandatory for now and pass it a { } if parameter is undefined.
Refactoring to make it optional sounds good as a follow-up.
Comment 7 youenn fablet 2016-10-27 07:05:48 PDT
Related test LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor.html seems to expect that a null parameter should not throw.
Comment 8 Nael Ouedraogo 2016-12-19 07:06:41 PST
Created attachment 297458 [details]
Patch
Comment 9 youenn fablet 2016-12-19 07:21:57 PST
Comment on attachment 297458 [details]
Patch

LGTM.

View in context: https://bugs.webkit.org/attachment.cgi?id=297458&action=review

> Source/WebCore/Modules/mediastream/RTCPeerConnection.js:40
>      if (!@isObject(configuration))

You could add "else if" here

> LayoutTests/fast/mediastream/RTCPeerConnection.html:12
> +            shouldNotThrow("new RTCPeerConnection();");

Maybe we can remove those two tests since they are not providing more than what the wpt tests provide already?
Comment 10 Nael Ouedraogo 2016-12-19 09:06:43 PST
Thanks for the review and comments.
 
> > Source/WebCore/Modules/mediastream/RTCPeerConnection.js:40
> >      if (!@isObject(configuration))
> 
> You could add "else if" here
Ok I will upload a new patch.

> > LayoutTests/fast/mediastream/RTCPeerConnection.html:12
> > +            shouldNotThrow("new RTCPeerConnection();");
> 
> Maybe we can remove those two tests since they are not providing more than
> what the wpt tests provide already?
Ok.
Comment 11 Nael Ouedraogo 2016-12-19 09:15:54 PST
(In reply to comment #7)
> Related test
> LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/
> rtcpeerconnection-constructor.html seems to expect that a null parameter
> should not throw.
I think it should throw as per specification (https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection).
Comment 12 youenn fablet 2016-12-19 09:48:01 PST
(In reply to comment #11)
> (In reply to comment #7)
> > Related test
> > LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/
> > rtcpeerconnection-constructor.html seems to expect that a null parameter
> > should not throw.
> I think it should throw as per specification
> (https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection).

Right, I think chromium and firefox accept null parameters currently, while webkit does not.
We should try to converge on that issue.
Comment 13 Nael Ouedraogo 2016-12-19 10:04:49 PST
Created attachment 297463 [details]
Patch
Comment 14 Nael Ouedraogo 2016-12-20 02:12:01 PST
Thanks for the review!
Comment 15 WebKit Commit Bot 2016-12-20 02:25:20 PST
Comment on attachment 297463 [details]
Patch

Clearing flags on attachment: 297463

Committed r210017: <http://trac.webkit.org/changeset/210017>
Comment 16 WebKit Commit Bot 2016-12-20 02:25:24 PST
All reviewed patches have been landed.  Closing bug.