Changeset 226804 in webkit


Ignore:
Timestamp:
Jan 11, 2018 1:54:23 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

RTCController should disable ICE candidate filtering in case of getUserMedia based on the RTCPerrConnection origin
https://bugs.webkit.org/show_bug.cgi?id=180851

Patch by Youenn Fablet <youenn@apple.com> on 2018-01-11
Reviewed by Eric Carlson.

Source/WebCore:

Test: http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html

RTCController now stores all the client origins (top+frame origins) of frames that got access to camera/microphone access.
For any such client origin, PeerConnection objects ICE candidate filtering is disabled.
ICE candidate filtering is reset whenever navigating/reloading the page.

  • Modules/mediastream/RTCController.cpp:

(WebCore::RTCController::reset):
(WebCore::matchDocumentOrigin):
(WebCore::RTCController::shouldDisableICECandidateFiltering):
(WebCore::RTCController::add):
(WebCore::RTCController::disableICECandidateFilteringForAllOrigins):
(WebCore::RTCController::disableICECandidateFiltering):
(WebCore::RTCController::enableICECandidateFiltering):

  • Modules/mediastream/RTCController.h:
  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::create):

  • Modules/mediastream/UserMediaRequest.cpp:

(WebCore::UserMediaRequest::allow):

  • page/Page.cpp:

(WebCore::Page::disableICECandidateFiltering):

  • testing/Internals.cpp:

(WebCore::Internals::setICECandidateFiltering):

LayoutTests:

  • http/wpt/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html: Added.
  • http/wpt/webrtc/third-party-frame-ice-candidate-filtering-expected.txt: Added.
  • http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html: Added.
Location:
trunk
Files:
5 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r226802 r226804  
     12018-01-11  Youenn Fablet  <youenn@apple.com>
     2
     3        RTCController should disable ICE candidate filtering in case of getUserMedia based on the RTCPerrConnection origin
     4        https://bugs.webkit.org/show_bug.cgi?id=180851
     5
     6        Reviewed by Eric Carlson.
     7
     8        * http/wpt/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html: Added.
     9        * http/wpt/webrtc/third-party-frame-ice-candidate-filtering-expected.txt: Added.
     10        * http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html: Added.
     11
    1122018-01-11  Ali Juma  <ajuma@chromium.org>
    213
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r226375 r226804  
    131131webrtc [ Skip ]
    132132http/tests/webrtc [ Skip ]
     133http/wpt/webrtc [ Skip ]
    133134webrtc/datachannel [ Pass ]
    134135webrtc/datachannel/bufferedAmountLowThreshold.html [ Pass Failure ]
  • trunk/Source/WebCore/ChangeLog

    r226802 r226804  
     12018-01-11  Youenn Fablet  <youenn@apple.com>
     2
     3        RTCController should disable ICE candidate filtering in case of getUserMedia based on the RTCPerrConnection origin
     4        https://bugs.webkit.org/show_bug.cgi?id=180851
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test: http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html
     9
     10        RTCController now stores all the client origins (top+frame origins) of frames that got access to camera/microphone access.
     11        For any such client origin, PeerConnection objects ICE candidate filtering is disabled.
     12        ICE candidate filtering is reset whenever navigating/reloading the page.
     13
     14        * Modules/mediastream/RTCController.cpp:
     15        (WebCore::RTCController::reset):
     16        (WebCore::matchDocumentOrigin):
     17        (WebCore::RTCController::shouldDisableICECandidateFiltering):
     18        (WebCore::RTCController::add):
     19        (WebCore::RTCController::disableICECandidateFilteringForAllOrigins):
     20        (WebCore::RTCController::disableICECandidateFiltering):
     21        (WebCore::RTCController::enableICECandidateFiltering):
     22        * Modules/mediastream/RTCController.h:
     23        * Modules/mediastream/RTCPeerConnection.cpp:
     24        (WebCore::RTCPeerConnection::create):
     25        * Modules/mediastream/UserMediaRequest.cpp:
     26        (WebCore::UserMediaRequest::allow):
     27        * page/Page.cpp:
     28        (WebCore::Page::disableICECandidateFiltering):
     29        * testing/Internals.cpp:
     30        (WebCore::Internals::setICECandidateFiltering):
     31
    1322018-01-11  Ali Juma  <ajuma@chromium.org>
    233
  • trunk/Source/WebCore/Modules/mediastream/RTCController.cpp

    r219331 r226804  
    4545        connection.clearController();
    4646    m_peerConnections.clear();
     47    m_filteringDisabledOrigins.clear();
    4748}
    4849
     
    5455}
    5556
     57static inline bool matchDocumentOrigin(Document& document, SecurityOrigin& topOrigin, SecurityOrigin& clientOrigin)
     58{
     59    if (originsMatch(topOrigin, document.securityOrigin()))
     60        return true;
     61    return originsMatch(topOrigin, document.topOrigin()) && originsMatch(clientOrigin, document.securityOrigin());
     62}
     63
     64bool RTCController::shouldDisableICECandidateFiltering(Document& document)
     65{
     66    if (!m_shouldFilterICECandidates)
     67        return true;
     68    return notFound != m_filteringDisabledOrigins.findMatching([&] (const auto& origin) {
     69        return matchDocumentOrigin(document, origin.topOrigin, origin.clientOrigin);
     70    });
     71}
     72
    5673void RTCController::add(RTCPeerConnection& connection)
    5774{
    5875    m_peerConnections.append(connection);
    59     if (!m_shouldFilterICECandidates)
     76    if (shouldDisableICECandidateFiltering(downcast<Document>(*connection.scriptExecutionContext())))
    6077        connection.disableICECandidateFiltering();
    6178}
    6279
    63 void RTCController::disableICECandidateFiltering()
     80void RTCController::disableICECandidateFilteringForAllOrigins()
    6481{
    6582    if (!LibWebRTCProvider::webRTCAvailable())
     
    7188}
    7289
     90void RTCController::disableICECandidateFilteringForDocument(Document& document)
     91{
     92    if (!LibWebRTCProvider::webRTCAvailable())
     93        return;
     94
     95    m_filteringDisabledOrigins.append(PeerConnectionOrigin { document.topOrigin(), document.securityOrigin() });
     96    for (RTCPeerConnection& connection : m_peerConnections) {
     97        if (auto* peerConnectionDocument = downcast<Document>(connection.scriptExecutionContext())) {
     98            if (matchDocumentOrigin(*peerConnectionDocument, document.topOrigin(), document.securityOrigin()))
     99                connection.disableICECandidateFiltering();
     100        }
     101    }
     102}
     103
    73104void RTCController::enableICECandidateFiltering()
    74105{
     
    76107        return;
    77108
     109    m_filteringDisabledOrigins.clear();
    78110    m_shouldFilterICECandidates = true;
    79111    for (RTCPeerConnection& connection : m_peerConnections)
  • trunk/Source/WebCore/Modules/mediastream/RTCController.h

    r219331 r226804  
    2525#pragma once
    2626
     27#include "SecurityOrigin.h"
    2728#include <wtf/Vector.h>
    2829
    2930namespace WebCore {
    3031
     32class Document;
    3133class RTCPeerConnection;
    3234
     
    4345    void remove(RTCPeerConnection&);
    4446
    45     WEBCORE_EXPORT void disableICECandidateFiltering();
     47    WEBCORE_EXPORT void disableICECandidateFilteringForAllOrigins();
     48    WEBCORE_EXPORT void disableICECandidateFilteringForDocument(Document&);
    4649    WEBCORE_EXPORT void enableICECandidateFiltering();
    4750
    4851private:
     52
     53    bool shouldDisableICECandidateFiltering(Document&);
     54
     55    struct PeerConnectionOrigin {
     56        Ref<SecurityOrigin> topOrigin;
     57        Ref<SecurityOrigin> clientOrigin;
     58    };
     59    Vector<PeerConnectionOrigin> m_filteringDisabledOrigins;
    4960    Vector<std::reference_wrapper<RTCPeerConnection>> m_peerConnections;
    5061    bool m_shouldFilterICECandidates { true };
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r224459 r226804  
    7070    if (!peerConnection->isClosed()) {
    7171        peerConnection->setPendingActivity(peerConnection.ptr());
    72 
    73         // ICE candidate filtering can only be disabled for connections from documents that have the same origin as the top document,
    74         // or if the page was set to disable it.
    75         auto& document = downcast<Document>(context);
    76         auto* page = document.page();
    77         if (page && (!page->shouldEnableICECandidateFilteringByDefault() || document.origin() == document.topDocument().origin()))
     72        if (auto* page = downcast<Document>(context).page())
    7873            peerConnection->registerToController(page->rtcController());
    7974    }
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp

    r226383 r226804  
    252252
    253253#if ENABLE(WEB_RTC)
    254     auto* page = downcast<Document>(*m_scriptExecutionContext).page();
    255     if (page)
    256         page->rtcController().disableICECandidateFiltering();
     254    auto& document = downcast<Document>(*m_scriptExecutionContext);
     255    if (auto* page = document.page())
     256        page->rtcController().disableICECandidateFilteringForDocument(document);
    257257#endif
    258258}
  • trunk/Source/WebCore/page/Page.cpp

    r225449 r226804  
    23312331    m_shouldEnableICECandidateFilteringByDefault = false;
    23322332#if ENABLE(WEB_RTC)
    2333     m_rtcController.disableICECandidateFiltering();
     2333    m_rtcController.disableICECandidateFilteringForAllOrigins();
    23342334#endif
    23352335}
  • trunk/Source/WebCore/testing/Internals.cpp

    r226526 r226804  
    13171317        rtcController.enableICECandidateFiltering();
    13181318    else
    1319         rtcController.disableICECandidateFiltering();
     1319        rtcController.disableICECandidateFilteringForAllOrigins();
    13201320}
    13211321
Note: See TracChangeset for help on using the changeset viewer.