haikuwebkit/LayoutTests/fast/mediastream/RTCPeerConnection-media-set...

117 lines
4.2 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/promise-utils.js"></script>
</head>
<body>
<script>
let stream;
let offer;
description("Test setting up media between two RTCPeerConnection instances with a single SDP dialog using legacy callbacks API.");
if (window.testRunner)
testRunner.setUserMediaPermission(true);
else {
debug("This test can not be run without the testRunner");
finishJSTest();
}
debug("Create RTCPeerConnection A");
Expose RTCPeerConnection unprefixed https://bugs.webkit.org/show_bug.cgi?id=164060 Patch by Youenn Fablet <youenn@apple.com> on 2016-10-28 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/webrtc/datachannel-emptystring-expected.txt: Added. * web-platform-tests/webrtc/no-media-call-expected.txt: Added. * web-platform-tests/webrtc/promises-call-expected.txt: Added. * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt: Added. * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt: Added. * web-platform-tests/webrtc/simplecall-expected.txt: Added. Source/WebCore: Covered by rebased and activated tests. * Modules/mediastream/RTCPeerConnection.idl: LayoutTests: * TestExpectations: * fast/mediastream/RTCPeerConnection-AddRemoveStream.html: * fast/mediastream/RTCPeerConnection-add-removeTrack-expected.txt: * fast/mediastream/RTCPeerConnection-add-removeTrack.html: * fast/mediastream/RTCPeerConnection-addIceCandidate.html: * fast/mediastream/RTCPeerConnection-addTrack-reuse-sender.html: * fast/mediastream/RTCPeerConnection-addTransceiver.html: * fast/mediastream/RTCPeerConnection-closed-state-expected.txt: * fast/mediastream/RTCPeerConnection-closed-state.html: * fast/mediastream/RTCPeerConnection-createAnswer.html: * fast/mediastream/RTCPeerConnection-createOffer.html: * fast/mediastream/RTCPeerConnection-datachannel.html: * fast/mediastream/RTCPeerConnection-dtmf.html: * fast/mediastream/RTCPeerConnection-events.html: * fast/mediastream/RTCPeerConnection-expected.txt: * fast/mediastream/RTCPeerConnection-getConfiguration.html: * fast/mediastream/RTCPeerConnection-have-local-offer.html: * fast/mediastream/RTCPeerConnection-have-local-pranswer.html: * fast/mediastream/RTCPeerConnection-have-remote-offer.html: * fast/mediastream/RTCPeerConnection-have-remote-pranswer.html: * fast/mediastream/RTCPeerConnection-ice-expected.txt: * fast/mediastream/RTCPeerConnection-ice.html: * fast/mediastream/RTCPeerConnection-icecandidate-event.html: * fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html: * fast/mediastream/RTCPeerConnection-inspect-answer.html: * fast/mediastream/RTCPeerConnection-inspect-offer.html: * fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt: * fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html: * fast/mediastream/RTCPeerConnection-legacy-stream-based-api.html: * fast/mediastream/RTCPeerConnection-localDescription.html: * fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html: * fast/mediastream/RTCPeerConnection-media-setup-single-dialog.html: * fast/mediastream/RTCPeerConnection-media-setup-two-dialogs.html: * fast/mediastream/RTCPeerConnection-more-media-to-negotiate.html: * fast/mediastream/RTCPeerConnection-onnegotiationneeded.html: * fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt: * fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt: * fast/mediastream/RTCPeerConnection-overloaded-operations-params.html: * fast/mediastream/RTCPeerConnection-overloaded-operations.html: * fast/mediastream/RTCPeerConnection-remoteDescription.html: * fast/mediastream/RTCPeerConnection-remotely-assigned-transceiver-mid.html: * fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html: * fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html: * fast/mediastream/RTCPeerConnection-stable.html: * fast/mediastream/RTCPeerConnection-stats-expected.txt: * fast/mediastream/RTCPeerConnection-stats.html: * fast/mediastream/RTCPeerConnection-statsSelector-expected.txt: * fast/mediastream/RTCPeerConnection-statsSelector.html: * fast/mediastream/RTCPeerConnection.html: * fast/mediastream/RTCRtpSender-replaceTrack.html: * fast/mediastream/RTCTrackEvent-constructor.html: * platform/efl/TestExpectations: * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/181842@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-28 18:09:41 +00:00
const pcA = new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
debug("Create RTCPeerConnection B");
Expose RTCPeerConnection unprefixed https://bugs.webkit.org/show_bug.cgi?id=164060 Patch by Youenn Fablet <youenn@apple.com> on 2016-10-28 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/webrtc/datachannel-emptystring-expected.txt: Added. * web-platform-tests/webrtc/no-media-call-expected.txt: Added. * web-platform-tests/webrtc/promises-call-expected.txt: Added. * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt: Added. * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt: Added. * web-platform-tests/webrtc/simplecall-expected.txt: Added. Source/WebCore: Covered by rebased and activated tests. * Modules/mediastream/RTCPeerConnection.idl: LayoutTests: * TestExpectations: * fast/mediastream/RTCPeerConnection-AddRemoveStream.html: * fast/mediastream/RTCPeerConnection-add-removeTrack-expected.txt: * fast/mediastream/RTCPeerConnection-add-removeTrack.html: * fast/mediastream/RTCPeerConnection-addIceCandidate.html: * fast/mediastream/RTCPeerConnection-addTrack-reuse-sender.html: * fast/mediastream/RTCPeerConnection-addTransceiver.html: * fast/mediastream/RTCPeerConnection-closed-state-expected.txt: * fast/mediastream/RTCPeerConnection-closed-state.html: * fast/mediastream/RTCPeerConnection-createAnswer.html: * fast/mediastream/RTCPeerConnection-createOffer.html: * fast/mediastream/RTCPeerConnection-datachannel.html: * fast/mediastream/RTCPeerConnection-dtmf.html: * fast/mediastream/RTCPeerConnection-events.html: * fast/mediastream/RTCPeerConnection-expected.txt: * fast/mediastream/RTCPeerConnection-getConfiguration.html: * fast/mediastream/RTCPeerConnection-have-local-offer.html: * fast/mediastream/RTCPeerConnection-have-local-pranswer.html: * fast/mediastream/RTCPeerConnection-have-remote-offer.html: * fast/mediastream/RTCPeerConnection-have-remote-pranswer.html: * fast/mediastream/RTCPeerConnection-ice-expected.txt: * fast/mediastream/RTCPeerConnection-ice.html: * fast/mediastream/RTCPeerConnection-icecandidate-event.html: * fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html: * fast/mediastream/RTCPeerConnection-inspect-answer.html: * fast/mediastream/RTCPeerConnection-inspect-offer.html: * fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt: * fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html: * fast/mediastream/RTCPeerConnection-legacy-stream-based-api.html: * fast/mediastream/RTCPeerConnection-localDescription.html: * fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html: * fast/mediastream/RTCPeerConnection-media-setup-single-dialog.html: * fast/mediastream/RTCPeerConnection-media-setup-two-dialogs.html: * fast/mediastream/RTCPeerConnection-more-media-to-negotiate.html: * fast/mediastream/RTCPeerConnection-onnegotiationneeded.html: * fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt: * fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt: * fast/mediastream/RTCPeerConnection-overloaded-operations-params.html: * fast/mediastream/RTCPeerConnection-overloaded-operations.html: * fast/mediastream/RTCPeerConnection-remoteDescription.html: * fast/mediastream/RTCPeerConnection-remotely-assigned-transceiver-mid.html: * fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html: * fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html: * fast/mediastream/RTCPeerConnection-stable.html: * fast/mediastream/RTCPeerConnection-stats-expected.txt: * fast/mediastream/RTCPeerConnection-stats.html: * fast/mediastream/RTCPeerConnection-statsSelector-expected.txt: * fast/mediastream/RTCPeerConnection-statsSelector.html: * fast/mediastream/RTCPeerConnection.html: * fast/mediastream/RTCRtpSender-replaceTrack.html: * fast/mediastream/RTCTrackEvent-constructor.html: * platform/efl/TestExpectations: * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/181842@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-28 18:09:41 +00:00
const pcB = new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
pcA.ontrack = function () {
debug("----------");
testPassed("A: got remote track event");
debug("----------");
};
pcB.ontrack = function () {
debug("----------");
testPassed("B: got remote track event");
debug("----------");
};
navigator.mediaDevices.getUserMedia({ "audio": true })
.then(function (s) {
stream = s;
return startTestWithMedia();
})
.catch(function (error) {
testFailed(`Unable to get user media: ${error}`);
finishJSTest();
});
function startTestWithMedia() {
debug("A: add media");
pcA.addTrack(stream.getAudioTracks()[0], stream);
debug("A: create offer");
return pcA.createOffer().then(offer => {
debug("A: got offer, set it as local description");
return pcA.setLocalDescription(offer).then(() => {
debug("A: local offer set");
shouldBe("pcA.signalingState", "'have-local-offer'");
debug("A: send offer to B");
debug("A --- offer --> B");
return offerToPcB(pcA.localDescription);
}, gotError);
}, gotError);
}
function offerToPcB(offer) {
debug("B: got offer from A, set it as remote description");
return pcB.setRemoteDescription(offer).then(() => {
debug("B: remote offer set");
shouldBe("pcB.signalingState", "'have-remote-offer'");
debug("B: add media (to include in answer)");
pcB.addTrack(stream.getAudioTracks()[0], stream);
debug("B: create answer");
return pcB.createAnswer().then(answer => {
debug("B: got answer, set it as local description");
return pcB.setLocalDescription(answer).then(() => {
debug("B: local answer set");
shouldBe("pcB.signalingState", "'stable'");
debug("B: send answer to A");
debug("A <-- answer -- B");
return answerToA(pcB.localDescription);
}, gotError);
}, gotError);
}, gotError);
}
function answerToA(answer) {
debug("A: got answer from B, set it as remote description");
return pcA.setRemoteDescription(answer).then(() => {
debug("A: remote answer set");
shouldBe("pcA.signalingState", "'stable'");
testPassed("Offer/answer dialog completed")
debug("");
finishJSTest();
}, gotError);
}
function gotError() {
testFailed("Unexpected error callback fired");
}
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>