haikuwebkit/LayoutTests/webrtc/utf8-sdp.html

40 lines
1.3 KiB
HTML
Raw Permalink Normal View History

Preventively expect UTF8 strings from libwebrtc SDP and error messages https://bugs.webkit.org/show_bug.cgi?id=184509 Reviewed by Eric Carlson. Source/WebCore: Make WebCore code expect any libwebrtc string to contain UTF-8. Currently SDPs do not contain any UTF-8 specific character but https://tools.ietf.org/html/rfc4566 allows it. Add Internals API to set track id so that we can inject UTF-8 inside some WebRTC tests. Test: webrtc/utf8-sdp.html * Modules/mediastream/MediaStreamTrack.h: (WebCore::MediaStreamTrack::setIdForTesting): * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::fromStdString): (WebCore::fromSessionDescription): (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription): (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription): (WebCore::LibWebRTCMediaEndpoint::mediaStreamFromRTCStream): (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack): (WebCore::LibWebRTCMediaEndpoint::addDataChannel): (WebCore::LibWebRTCMediaEndpoint::OnIceCandidate): (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded): (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): (WebCore::trackId): Deleted. * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::fromStdString): (WebCore::LibWebRTCPeerConnectionBackend::doAddIceCandidate): (WebCore::createReceiverForSource): * platform/mediastream/MediaStreamTrackPrivate.h: (WebCore::MediaStreamTrackPrivate::setIdForTesting): * testing/Internals.cpp: (WebCore::Internals::setMediaStreamTrackIdentifier): * testing/Internals.h: * testing/Internals.idl: LayoutTests: * webrtc/utf8-sdp-expected.txt: Added. * webrtc/utf8-sdp.html: Added. Canonical link: https://commits.webkit.org/200065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-11 21:49:28 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing UTF-8 content in SDP</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="video" autoplay=""></video>
<script src ="routines.js"></script>
<script>
promise_test(async (test) => {
if (!window.internals)
return Promise.reject("internals required");
const unicodeString = '世界你好';
const stream = await navigator.mediaDevices.getUserMedia({video: true});
internals.setMediaStreamTrackIdentifier(stream.getVideoTracks()[0], unicodeString);
const remoteStream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
firstConnection.addTrack(stream.getVideoTracks()[0], stream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
assert_equals(unicodeString, remoteStream.getVideoTracks()[0].id);
video.srcObject = remoteStream;
return video.play();
}, "Testing video exchange with UTF-8 track id");
</script>
</body>
</html>