Changeset 282198 in webkit


Ignore:
Timestamp:
Sep 9, 2021 12:21:18 AM (10 months ago)
Author:
youenn@apple.com
Message:

Add support for RTCDataChannel closing event
https://bugs.webkit.org/show_bug.cgi?id=229988

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

  • web-platform-tests/webrtc/RTCDataChannel-close-expected.txt:
  • web-platform-tests/webrtc/idlharness.https.window-expected.txt:

Source/WebCore:

Add support for the closing event.
Updating close method as per https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-close:

  • make the channel enter closing state (without firing event)
  • wait for the state to move to closed from the backend.

We also add support for the error event by checking, when entering closed state whether
the channel is in an error state.

Covered by rebased test.

  • Modules/mediastream/RTCDataChannel.cpp:

(WebCore::RTCDataChannel::close):
(WebCore::RTCDataChannel::didChangeReadyState):
(WebCore::RTCDataChannel::stop):

  • Modules/mediastream/RTCDataChannel.idl:
  • Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:

(WebCore::LibWebRTCDataChannelHandler::checkState):

  • dom/EventNames.h:

LayoutTests:

Unskip no longer timing out test.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282197 r282198  
     12021-09-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for RTCDataChannel closing event
     4        https://bugs.webkit.org/show_bug.cgi?id=229988
     5
     6        Reviewed by Eric Carlson.
     7
     8        * TestExpectations:
     9        Unskip no longer timing out test.
     10
    1112021-09-09  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r282195 r282198  
    21952195imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-remote-track-mute.https.html [ Skip ]
    21962196imported/w3c/web-platform-tests/webrtc/RTCDataChannel-bufferedAmount.html [ Skip ]
    2197 imported/w3c/web-platform-tests/webrtc/RTCDataChannel-close.html [ Skip ]
    21982197imported/w3c/web-platform-tests/webrtc/RTCIceConnectionState-candidate-pair.https.html [ Skip ]
    21992198imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-mandatory-getStats.https.html [ Skip ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r282197 r282198  
     12021-09-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for RTCDataChannel closing event
     4        https://bugs.webkit.org/show_bug.cgi?id=229988
     5
     6        Reviewed by Eric Carlson.
     7
     8        * web-platform-tests/webrtc/RTCDataChannel-close-expected.txt:
     9        * web-platform-tests/webrtc/idlharness.https.window-expected.txt:
     10
    1112021-09-09  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-close-expected.txt

    r267649 r282198  
    11
    2 Harness Error (TIMEOUT), message = null
     2PASS Close datachannel causes onclosing and onclose to be called
     3PASS Close datachannel causes closing and close event to be called
     4FAIL Close peerconnection causes close event and error to be called on datachannel Can't find variable: RTCErrorEvent
     5PASS Close peerconnection after datachannel close causes no events
     6PASS Close negotiated datachannel causes onclosing and onclose to be called
     7PASS Close negotiated datachannel causes closing and close event to be called
     8FAIL Close peerconnection causes close event and error to be called on negotiated datachannel Can't find variable: RTCErrorEvent
     9PASS Close peerconnection after negotiated datachannel close causes no events
    310
    4 FAIL Close datachannel causes onclosing and onclose to be called assert_true: Closing event was seen expected true got false
    5 FAIL Close datachannel causes closing and close event to be called assert_true: Closing event was seen expected true got false
    6 FAIL Close peerconnection causes close event and error to be called on datachannel assert_array_equals: lengths differ, expected array ["error", "close"] length 2, got ["close"] length 1
    7 TIMEOUT Close peerconnection after datachannel close causes no events Test timed out
    8 NOTRUN Close negotiated datachannel causes onclosing and onclose to be called
    9 NOTRUN Close negotiated datachannel causes closing and close event to be called
    10 NOTRUN Close peerconnection causes close event and error to be called on negotiated datachannel
    11 NOTRUN Close peerconnection after negotiated datachannel close causes no events
    12 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/idlharness.https.window-expected.txt

    r282197 r282198  
    405405PASS RTCDataChannel interface: attribute onbufferedamountlow
    406406PASS RTCDataChannel interface: attribute onerror
    407 FAIL RTCDataChannel interface: attribute onclosing assert_true: The prototype object must have a property "onclosing" expected true got false
     407PASS RTCDataChannel interface: attribute onclosing
    408408PASS RTCDataChannel interface: attribute onclose
    409409PASS RTCDataChannel interface: operation close()
     
    429429PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onbufferedamountlow" with the proper type
    430430PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onerror" with the proper type
    431 FAIL RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onclosing" with the proper type assert_inherits: property "onclosing" not found in prototype chain
     431PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onclosing" with the proper type
    432432PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onclose" with the proper type
    433433PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "close()" with the proper type
  • trunk/Source/WebCore/ChangeLog

    r282197 r282198  
     12021-09-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for RTCDataChannel closing event
     4        https://bugs.webkit.org/show_bug.cgi?id=229988
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add support for the closing event.
     9        Updating close method as per https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-close:
     10        - make the channel enter closing state (without firing event)
     11        - wait for the state to move to closed from the backend.
     12
     13        We also add support for the error event by checking, when entering closed state whether
     14        the channel is in an error state.
     15
     16        Covered by rebased test.
     17
     18        * Modules/mediastream/RTCDataChannel.cpp:
     19        (WebCore::RTCDataChannel::close):
     20        (WebCore::RTCDataChannel::didChangeReadyState):
     21        (WebCore::RTCDataChannel::stop):
     22        * Modules/mediastream/RTCDataChannel.idl:
     23        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
     24        (WebCore::LibWebRTCDataChannelHandler::checkState):
     25        * dom/EventNames.h:
     26
    1272021-09-09  Youenn Fablet  <youenn@apple.com>
    228
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp

    r278702 r282198  
    176176        return;
    177177
    178     m_stopped = true;
    179     m_readyState = RTCDataChannelState::Closed;
     178    if (m_readyState == RTCDataChannelState::Closing || m_readyState == RTCDataChannelState::Closed)
     179        return;
     180
     181    m_readyState = RTCDataChannelState::Closing;
    180182
    181183    m_messageQueue.clear();
     
    183185    if (m_handler)
    184186        m_handler->close();
    185     m_handler = nullptr;
    186187}
    187188
     
    199200
    200201    switch (m_readyState) {
     202    case RTCDataChannelState::Connecting:
     203        ASSERT_NOT_REACHED();
     204        break;
    201205    case RTCDataChannelState::Open:
    202206        scheduleDispatchEvent(Event::create(eventNames().openEvent, Event::CanBubble::No, Event::IsCancelable::No));
    203207        break;
     208    case RTCDataChannelState::Closing:
     209        scheduleDispatchEvent(Event::create(eventNames().closingEvent, Event::CanBubble::No, Event::IsCancelable::No));
     210        break;
    204211    case RTCDataChannelState::Closed:
    205212        scheduleDispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
    206         break;
    207     default:
     213        m_stopped = true;
    208214        break;
    209215    }
     
    246252
    247253    close();
     254    m_stopped = true;
     255    m_handler = nullptr;
    248256}
    249257
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl

    r276204 r282198  
    5656    attribute EventHandler onerror;
    5757    attribute EventHandler onclose;
     58    attribute EventHandler onclosing;
    5859    attribute EventHandler onmessage;
    5960    attribute EventHandler onbufferedamountlow;
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp

    r278532 r282198  
    130130void LibWebRTCDataChannelHandler::checkState()
    131131{
     132    bool hasError = false;
    132133    RTCDataChannelState state;
    133134    switch (m_channel->state()) {
     
    142143        break;
    143144    case webrtc::DataChannelInterface::kClosed:
     145        hasError = !m_channel->error().ok();
    144146        state = RTCDataChannelState::Closed;
    145147        break;
     
    151153        return;
    152154    }
    153     postTask([protectedClient = makeRef(*m_client), state] {
     155    postTask([protectedClient = makeRef(*m_client), state, hasError] {
     156        if (hasError)
     157            protectedClient->didDetectError();
    154158        protectedClient->didChangeReadyState(state);
    155159    });
  • trunk/Source/WebCore/dom/EventNames.h

    r281796 r282198  
    9090    macro(click) \
    9191    macro(close) \
     92    macro(closing) \
    9293    macro(complete) \
    9394    macro(compositionend) \
Note: See TracChangeset for help on using the changeset viewer.