Changeset 230970 in webkit


Ignore:
Timestamp:
Apr 24, 2018 1:22:51 PM (6 years ago)
Author:
youenn@apple.com
Message:

Throw in case of PeerConnection created for detached documents
https://bugs.webkit.org/show_bug.cgi?id=184921
<rdar://problem/39629216>

Reviewed by Eric Carlson.

Source/WebCore:

Add a check to ensure that page is not null when creating a peer connection backend.
In that case, the peer connection constructor will later on throw.
The same for setConfiguration is done.
Behavior is consistent with Chrome.

Test: webrtc/pc-detached-document.html

  • Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:

(WebCore::createLibWebRTCPeerConnectionBackend):
(WebCore::LibWebRTCPeerConnectionBackend::LibWebRTCPeerConnectionBackend):
(WebCore::LibWebRTCPeerConnectionBackend::setConfiguration):
(WebCore::libWebRTCProvider): Deleted.

  • Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:

LayoutTests:

  • webrtc/pc-detached-document-expected.txt: Added.
  • webrtc/pc-detached-document.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r230968 r230970  
     12018-04-24  Youenn Fablet  <youenn@apple.com>
     2
     3        Throw in case of PeerConnection created for detached documents
     4        https://bugs.webkit.org/show_bug.cgi?id=184921
     5        <rdar://problem/39629216>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * webrtc/pc-detached-document-expected.txt: Added.
     10        * webrtc/pc-detached-document.html: Added.
     11
    1122018-04-24  John Wilander  <wilander@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r230968 r230970  
     12018-04-24  Youenn Fablet  <youenn@apple.com>
     2
     3        Throw in case of PeerConnection created for detached documents
     4        https://bugs.webkit.org/show_bug.cgi?id=184921
     5        <rdar://problem/39629216>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Add a check to ensure that page is not null when creating a peer connection backend.
     10        In that case, the peer connection constructor will later on throw.
     11        The same for setConfiguration is done.
     12        Behavior is consistent with Chrome.
     13
     14        Test: webrtc/pc-detached-document.html
     15
     16        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
     17        (WebCore::createLibWebRTCPeerConnectionBackend):
     18        (WebCore::LibWebRTCPeerConnectionBackend::LibWebRTCPeerConnectionBackend):
     19        (WebCore::LibWebRTCPeerConnectionBackend::setConfiguration):
     20        (WebCore::libWebRTCProvider): Deleted.
     21        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
     22
    1232018-04-24  John Wilander  <wilander@apple.com>
    224
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp

    r230548 r230970  
    5050    if (!LibWebRTCProvider::webRTCAvailable())
    5151        return nullptr;
    52     return std::make_unique<LibWebRTCPeerConnectionBackend>(peerConnection);
     52
     53    auto* page = downcast<Document>(*peerConnection.scriptExecutionContext()).page();
     54    if (!page)
     55        return nullptr;
     56    return std::make_unique<LibWebRTCPeerConnectionBackend>(peerConnection, page->libWebRTCProvider());
    5357}
    5458
    5559CreatePeerConnectionBackend PeerConnectionBackend::create = createLibWebRTCPeerConnectionBackend;
    5660
    57 static inline LibWebRTCProvider& libWebRTCProvider(RTCPeerConnection& peerConnection)
    58 {
    59     return downcast<Document>(*peerConnection.scriptExecutionContext()).page()->libWebRTCProvider();
    60 }
    61 
    62 LibWebRTCPeerConnectionBackend::LibWebRTCPeerConnectionBackend(RTCPeerConnection& peerConnection)
     61LibWebRTCPeerConnectionBackend::LibWebRTCPeerConnectionBackend(RTCPeerConnection& peerConnection, LibWebRTCProvider& provider)
    6362    : PeerConnectionBackend(peerConnection)
    64     , m_endpoint(LibWebRTCMediaEndpoint::create(*this, libWebRTCProvider(peerConnection)))
     63    , m_endpoint(LibWebRTCMediaEndpoint::create(*this, provider))
    6564{
    6665}
     
    121120bool LibWebRTCPeerConnectionBackend::setConfiguration(MediaEndpointConfiguration&& configuration)
    122121{
    123     return m_endpoint->setConfiguration(libWebRTCProvider(m_peerConnection), configurationFromMediaEndpointConfiguration(WTFMove(configuration)));
     122    auto* page = downcast<Document>(*m_peerConnection.scriptExecutionContext()).page();
     123    if (!page)
     124        return false;
     125
     126    return m_endpoint->setConfiguration(page->libWebRTCProvider(), configurationFromMediaEndpointConfiguration(WTFMove(configuration)));
    124127}
    125128
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h

    r229645 r230970  
    3737
    3838class LibWebRTCMediaEndpoint;
     39class LibWebRTCProvider;
    3940class RTCRtpReceiver;
    4041class RTCSessionDescription;
     
    4748class LibWebRTCPeerConnectionBackend final : public PeerConnectionBackend {
    4849public:
    49     explicit LibWebRTCPeerConnectionBackend(RTCPeerConnection&);
     50    LibWebRTCPeerConnectionBackend(RTCPeerConnection&, LibWebRTCProvider&);
    5051    ~LibWebRTCPeerConnectionBackend();
    5152
Note: See TracChangeset for help on using the changeset viewer.