Changeset 214441 in webkit


Ignore:
Timestamp:
Mar 27, 2017 4:36:36 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

addIceCandidate should not throw if passed null or undefined
https://bugs.webkit.org/show_bug.cgi?id=170118

Patch by Youenn Fablet <youenn@apple.com> on 2017-03-27
Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

  • web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt:

Source/WebCore:

Covered by updated test.

A null/undefined candidate passed to addIceCandidate means end of Ice candidate..

  • Modules/mediastream/PeerConnectionBackend.cpp:

(WebCore::PeerConnectionBackend::addIceCandidate):

  • Modules/mediastream/PeerConnectionBackend.h:

(WebCore::PeerConnectionBackend::endOfIceCandidates):

  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::queuedAddIceCandidate):

  • Modules/mediastream/RTCPeerConnection.h:
  • Modules/mediastream/RTCPeerConnection.idl:
  • Modules/mediastream/RTCPeerConnection.js:

(addIceCandidate):

LayoutTests:

Updating test to log addIceCandidate rejection.

  • webrtc/datachannel/basic.html:
  • webrtc/routines.js:

(iceCallback1):
(iceCallback2):
(onAddIceCandidateError):

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214437 r214441  
     12017-03-27  Youenn Fablet  <youenn@apple.com>
     2
     3        addIceCandidate should not throw if passed null or undefined
     4        https://bugs.webkit.org/show_bug.cgi?id=170118
     5
     6        Reviewed by Eric Carlson.
     7
     8        Updating test to log addIceCandidate rejection.
     9
     10        * webrtc/datachannel/basic.html:
     11        * webrtc/routines.js:
     12        (iceCallback1):
     13        (iceCallback2):
     14        (onAddIceCandidateError):
     15
    1162017-03-27  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r214293 r214441  
     12017-03-27  Youenn Fablet  <youenn@apple.com>
     2
     3        addIceCandidate should not throw if passed null or undefined
     4        https://bugs.webkit.org/show_bug.cgi?id=170118
     5
     6        Reviewed by Eric Carlson.
     7
     8        * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt:
     9
    1102017-03-22  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt

    r211886 r214441  
    2424PASS RTCPeerConnection interface: attribute currentRemoteDescription
    2525PASS RTCPeerConnection interface: attribute pendingRemoteDescription
    26 FAIL RTCPeerConnection interface: operation addIceCandidate(RTCIceCandidate) assert_equals: property has wrong .length expected 1 but got 0
     26FAIL RTCPeerConnection interface: operation addIceCandidate([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
    2727PASS RTCPeerConnection interface: attribute signalingState
    2828PASS RTCPeerConnection interface: attribute iceGatheringState
     
    8080PASS RTCPeerConnection interface: pc must inherit property "pendingRemoteDescription" with the proper type (9)
    8181PASS RTCPeerConnection interface: pc must inherit property "addIceCandidate" with the proper type (10)
    82 PASS RTCPeerConnection interface: calling addIceCandidate(RTCIceCandidate) on pc with too few arguments must throw TypeError
     82FAIL RTCPeerConnection interface: calling addIceCandidate([object Object],[object Object]) on pc with too few arguments must throw TypeError assert_unreached: Should have rejected: undefined Reached unreachable code
    8383FAIL RTCPeerConnection interface: pc must inherit property "signalingState" with the proper type (11) Unrecognized type RTCSignalingState
    8484FAIL RTCPeerConnection interface: pc must inherit property "iceGatheringState" with the proper type (12) Unrecognized type RTCIceGatheringState
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html

    r207939 r214441  
    3434    readonly    attribute RTCSessionDescription? currentRemoteDescription;
    3535    readonly    attribute RTCSessionDescription? pendingRemoteDescription;
    36     Promise<void>                  addIceCandidate (RTCIceCandidate candidate);
     36    Promise<void>                  addIceCandidate ((RTCIceCandidateInit or RTCIceCandidate) candidate);
    3737    readonly    attribute RTCSignalingState      signalingState;
    3838    readonly    attribute RTCIceGatheringState   iceGatheringState;
  • trunk/LayoutTests/webrtc/datachannel/basic.html

    r214421 r214441  
    9696                remoteChannel.onmessage = receiveMessages;
    9797            };
    98         }, (candidate) => { return candidate.candidate.toLowerCase().indexOf("udp") == -1; });
     98        }, (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("udp") == -1; });
    9999    });
    100100}, "Basic data channel exchange from offerer to receiver using UDP only");
     
    115115                remoteChannel.onmessage = receiveMessages;
    116116            };
    117         }, (candidate) => { return candidate.candidate.toLowerCase().indexOf("tcp") == -1; });
     117        }, (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("tcp") == -1; });
    118118    });
    119119}, "Basic data channel exchange from offerer to receiver using TCP only");
  • trunk/LayoutTests/webrtc/routines.js

    r213983 r214441  
    4343function iceCallback1(event, filterOutICECandidate)
    4444{
    45     if (!event.candidate)
    46         return;
    47 
    4845    if (filterOutICECandidate && filterOutICECandidate(event.candidate))
    4946        return;
     
    5451function iceCallback2(event, filterOutICECandidate)
    5552{
    56     if (!event.candidate)
    57         return;
    58 
    5953    if (filterOutICECandidate && filterOutICECandidate(event.candidate))
    6054        return;
    6155
    62     if (event.candidate)
    63         localConnection.addIceCandidate(event.candidate).then(onAddIceCandidateSuccess, onAddIceCandidateError);
     56    localConnection.addIceCandidate(event.candidate).then(onAddIceCandidateSuccess, onAddIceCandidateError);
    6457}
    6558
     
    7063function onAddIceCandidateError(error)
    7164{
     65    console.log("addIceCandidate error: " + error)
    7266    assert_unreached();
    7367}
  • trunk/Source/WebCore/ChangeLog

    r214435 r214441  
     12017-03-27  Youenn Fablet  <youenn@apple.com>
     2
     3        addIceCandidate should not throw if passed null or undefined
     4        https://bugs.webkit.org/show_bug.cgi?id=170118
     5
     6        Reviewed by Eric Carlson.
     7
     8        Covered by updated test.
     9
     10        A null/undefined candidate passed to addIceCandidate means end of Ice candidate..
     11
     12        * Modules/mediastream/PeerConnectionBackend.cpp:
     13        (WebCore::PeerConnectionBackend::addIceCandidate):
     14        * Modules/mediastream/PeerConnectionBackend.h:
     15        (WebCore::PeerConnectionBackend::endOfIceCandidates):
     16        * Modules/mediastream/RTCPeerConnection.cpp:
     17        (WebCore::RTCPeerConnection::queuedAddIceCandidate):
     18        * Modules/mediastream/RTCPeerConnection.h:
     19        * Modules/mediastream/RTCPeerConnection.idl:
     20        * Modules/mediastream/RTCPeerConnection.js:
     21        (addIceCandidate):
     22
    1232017-03-27  Antti Koivisto  <antti@apple.com>
    224
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp

    r214330 r214441  
    226226}
    227227
    228 void PeerConnectionBackend::addIceCandidate(RTCIceCandidate& iceCandidate, DOMPromise<void>&& promise)
    229 {
    230     ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
    231 
    232     if (iceCandidate.sdpMid().isNull() && !iceCandidate.sdpMLineIndex()) {
     228void PeerConnectionBackend::addIceCandidate(RTCIceCandidate* iceCandidate, DOMPromise<void>&& promise)
     229{
     230    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
     231
     232    if (!iceCandidate) {
     233        endOfIceCandidates(WTFMove(promise));
     234        return;
     235    }
     236
     237    // FIXME: As per https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate(), this check should be done before enqueuing the task.
     238    if (iceCandidate->sdpMid().isNull() && !iceCandidate->sdpMLineIndex()) {
    233239        promise.reject(Exception { TypeError, ASCIILiteral("Trying to add a candidate that is missing both sdpMid and sdpMLineIndex") });
    234240        return;
    235241    }
    236242    m_addIceCandidatePromise = WTFMove(promise);
    237     doAddIceCandidate(iceCandidate);
     243    doAddIceCandidate(*iceCandidate);
    238244}
    239245
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h

    r214420 r214441  
    6363using CreatePeerConnectionBackend = std::unique_ptr<PeerConnectionBackend> (*)(RTCPeerConnection&);
    6464
    65 // FIXME: What is the value of this abstract class? There is only one concrete class derived from it.
    6665class PeerConnectionBackend {
    6766public:
     
    7574    void setLocalDescription(RTCSessionDescription&, DOMPromise<void>&&);
    7675    void setRemoteDescription(RTCSessionDescription&, DOMPromise<void>&&);
    77     void addIceCandidate(RTCIceCandidate&, DOMPromise<void>&&);
     76    void addIceCandidate(RTCIceCandidate*, DOMPromise<void>&&);
    7877
    7978    virtual std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) = 0;
     
    138137    virtual void doSetRemoteDescription(RTCSessionDescription&) = 0;
    139138    virtual void doAddIceCandidate(RTCIceCandidate&) = 0;
     139    virtual void endOfIceCandidates(DOMPromise<void>&& promise) { promise.resolve(); }
    140140    virtual void doStop() = 0;
    141141
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r214421 r214441  
    279279}
    280280
    281 void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate& rtcCandidate, DOMPromise<void>&& promise)
     281void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOMPromise<void>&& promise)
    282282{
    283283    if (m_signalingState == RTCSignalingState::Closed) {
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r214420 r214441  
    8787    RefPtr<RTCSessionDescription> pendingRemoteDescription() const;
    8888
    89     void queuedAddIceCandidate(RTCIceCandidate&, DOMPromise<void>&&);
     89    void queuedAddIceCandidate(RTCIceCandidate*, DOMPromise<void>&&);
    9090
    9191    RTCSignalingState signalingState() const { return m_signalingState; }
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl

    r214421 r214441  
    111111    [PrivateIdentifier] Promise<void> queuedSetLocalDescription(RTCSessionDescription description);
    112112    [PrivateIdentifier] Promise<void> queuedSetRemoteDescription(RTCSessionDescription description);
    113     [PrivateIdentifier] Promise<void> queuedAddIceCandidate(RTCIceCandidate candidate);
     113    [PrivateIdentifier] Promise<void> queuedAddIceCandidate(RTCIceCandidate? candidate);
    114114
    115115
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.js

    r214293 r214441  
    251251        "argName": "candidate",
    252252        "argType": "RTCIceCandidate",
    253         "maybeDictionary": "true"
     253        "maybeDictionary": "true",
     254        "defaultsToNull" : "true"
    254255    };
    255256    return @objectAndCallbacksOverload(arguments, "addIceCandidate", objectInfo, function (candidate) {
Note: See TracChangeset for help on using the changeset viewer.