<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160693] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160693">160693</a></dd>
<dt>Author</dt> <dd>thiago.lacerda@openbossa.org</dd>
<dt>Date</dt> <dd>2013-12-16 20:12:19 -0800 (Mon, 16 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Checking RTCPeerConnection signalingState before setting local/remoteDescription
https://bugs.webkit.org/show_bug.cgi?id=125655
Reviewed by Eric Carlson.
Before setting a session description RTCPeerConnection must check if it is in valid state for that SDP type.
Source/WebCore:
New tests: fast/mediastream/RTCPeerConnection-have-local-answer.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-stable.html
Modified: fast/mediastream/RTCPeerConnection-remoteDescription.html
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::checkStateForLocalDescription): Checks if the current state of RTCPeerConnection is
valid for the local SDP that is being set.
(WebCore::RTCPeerConnection::checkStateForRemoteDescription): Checks if the current state of RTCPeerConnection
is valid for the remote SDP that is being set.
(WebCore::RTCPeerConnection::setLocalDescription): Now calls checkStateForLocalDescription prior to set the
local SDP.
(WebCore::RTCPeerConnection::setRemoteDescription): Now Calls checkStateForRemoteDescription prior to set the
remote SDP.
* Modules/mediastream/RTCPeerConnection.h:
* platform/mock/RTCNotifiersMock.cpp: Adding new class to notify RTCPeerConnection about a signaling state
change: SignalingStateNotifier.
(WebCore::SignalingStateNotifier::SignalingStateNotifier):
(WebCore::SignalingStateNotifier::fire):
* platform/mock/RTCNotifiersMock.h:
* platform/mock/RTCPeerConnectionHandlerMock.cpp:
(WebCore::RTCPeerConnectionHandlerMock::signalingStateFromSDP): Defines the new state that RTCPeerConnection
should be, according the SDP that is being set.
(WebCore::RTCPeerConnectionHandlerMock::setLocalDescription): Calls signalingStateFromSDP, in order to get the
new signaling state and notify RTCPeerConnection object.
(WebCore::RTCPeerConnectionHandlerMock::setRemoteDescription): Ditto.
* platform/mock/RTCPeerConnectionHandlerMock.h:
LayoutTests:
* fast/mediastream/RTCPeerConnection-have-local-answer.html: Added.
* fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-have-local-offer.html: Added.
* fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-have-local-pranswer.html: Added.
* fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-have-remote-offer.html: Added.
* fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-have-remote-pranswer.html: Added.
* fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt:
* fast/mediastream/RTCPeerConnection-remoteDescription.html:
* fast/mediastream/RTCPeerConnection-stable-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-stable.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionremoteDescriptionexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionremoteDescriptionhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCPeerConnectioncpp">trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCPeerConnectionh">trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCNotifiersMockcpp">trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCNotifiersMockh">trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCPeerConnectionHandlerMockcpp">trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCPeerConnectionHandlerMockh">trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalanswerhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-answer.html</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalofferexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalofferhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer.html</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalpranswerexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalpranswerhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer.html</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremoteofferexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremoteofferhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer.html</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremotepranswerexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremotepranswerhtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer.html</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionstableexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionstablehtml">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/LayoutTests/ChangeLog        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2013-12-16 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org>
+
+ Checking RTCPeerConnection signalingState before setting local/remoteDescription
+ https://bugs.webkit.org/show_bug.cgi?id=125655
+
+ Reviewed by Eric Carlson.
+
+ Before setting a session description RTCPeerConnection must check if it is in valid state for that SDP type.
+
+ * fast/mediastream/RTCPeerConnection-have-local-answer.html: Added.
+ * fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt: Added.
+ * fast/mediastream/RTCPeerConnection-have-local-offer.html: Added.
+ * fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt: Added.
+ * fast/mediastream/RTCPeerConnection-have-local-pranswer.html: Added.
+ * fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt: Added.
+ * fast/mediastream/RTCPeerConnection-have-remote-offer.html: Added.
+ * fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt: Added.
+ * fast/mediastream/RTCPeerConnection-have-remote-pranswer.html: Added.
+ * fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt:
+ * fast/mediastream/RTCPeerConnection-remoteDescription.html:
+ * fast/mediastream/RTCPeerConnection-stable-expected.txt: Added.
+ * fast/mediastream/RTCPeerConnection-stable.html: Added.
+
</ins><span class="cx"> 2013-12-16 Oliver Hunt <oliver@apple.com>
</span><span class="cx">
</span><span class="cx"> Cache getters and custom accessors on the prototype chain
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalanswerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-answer.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-answer.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-answer.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection remoteDescription.");
+
+ var pc = null;
+
+ function requestFailed4(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ finishJSTest();
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function requestSucceeded2()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("answer", "local", "offer", "remote", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalofferexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+Tests RTCPeerConnection in have-local-offer state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded5, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "answer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "stable"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalofferhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-offer.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection in have-local-offer state.");
+
+ var pc = null;
+
+ function requestSucceeded5()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("offer", "local", "answer", "remote", '"stable"');
+ finishJSTest();
+ }
+
+ function requestSucceeded4()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded5, finishIfFailed);');
+ }
+
+ function requestSucceeded3()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+ }
+
+ function requestSucceeded2()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ } else {
+ shouldThrow('pc.localDescription');
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ } else {
+ shouldThrow('pc.remoteDescription');
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalpranswerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+Tests RTCPeerConnection in have-local-pranswer state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "answer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "stable"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhavelocalpranswerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-local-pranswer.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection in have-local-pranswer state.");
+
+ var pc = null;
+
+ function requestSucceeded4()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("answer", "local", "offer", "remote", '"stable"');
+ finishJSTest();
+ }
+
+ function requestFailed4(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function requestSucceeded3()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+ }
+
+ function requestSucceeded2()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremoteofferexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+Tests RTCPeerConnection in have-remote-offer state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "answer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "stable"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded5, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "pranswer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-local-pranswer"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremoteofferhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-offer.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection in have-remote-offer state.");
+
+ var pc = null;
+
+ function requestSucceeded5()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
+ finishJSTest();
+ }
+
+ function requestSucceeded4()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded5, finishIfFailed);');
+ }
+
+ function requestSucceeded3()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("answer", "local", "offer", "remote", '"stable"');
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+ }
+
+ function requestSucceeded2()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ } else {
+ shouldThrow('pc.localDescription');
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ } else {
+ shouldThrow('pc.remoteDescription');
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremotepranswerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+Tests RTCPeerConnection in have-remote-pranswer state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.signalingState is "have-local-offer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "pranswer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-pranswer"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription.type is "answer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "stable"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionhaveremotepranswerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-have-remote-pranswer.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection in have-remote-pranswer state.");
+
+ var pc = null;
+
+ function requestSucceeded4()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("offer", "local", "answer", "remote", '"stable"');
+ finishJSTest();
+ }
+
+ function requestFailed4(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function requestSucceeded3()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+ }
+
+ function requestSucceeded2()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("offer", "local", "", "", '"have-local-offer"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionremoteDescriptionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -7,9 +7,9 @@
</span><span class="cx"> PASS requestSucceeded was called.
</span><span class="cx"> PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, requestFailed2); did not throw exception.
</span><span class="cx"> PASS requestFailed was called.
</span><del>-PASS pc.remoteDescription.type is "answer"
</del><ins>+PASS pc.remoteDescription.type is "offer"
</ins><span class="cx"> PASS pc.remoteDescription.sdp is "remote"
</span><del>-PASS pc.remoteDescription.type is "answer"
</del><ins>+PASS pc.remoteDescription.type is "offer"
</ins><span class="cx"> PASS pc.remoteDescription.sdp is "remote"
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionremoteDescriptionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription.html (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription.html        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -13,10 +13,10 @@
</span><span class="cx"> {
</span><span class="cx"> testPassed('requestFailed was called.');
</span><span class="cx">
</span><del>- shouldBeEqualToString('pc.remoteDescription.type', "answer");
</del><ins>+ shouldBeEqualToString('pc.remoteDescription.type', "offer");
</ins><span class="cx"> shouldBeEqualToString('pc.remoteDescription.sdp', "remote");
</span><span class="cx"> pc.close();
</span><del>- shouldBeEqualToString('pc.remoteDescription.type', "answer");
</del><ins>+ shouldBeEqualToString('pc.remoteDescription.type', "offer");
</ins><span class="cx"> shouldBeEqualToString('pc.remoteDescription.sdp', "remote");
</span><span class="cx">
</span><span class="cx"> finishJSTest();
</span><span class="lines">@@ -38,12 +38,12 @@
</span><span class="cx"> {
</span><span class="cx"> testPassed('requestSucceeded was called.');
</span><span class="cx">
</span><del>- sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
</del><ins>+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
</ins><span class="cx"> shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, requestFailed2);');
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> pc = new webkitRTCPeerConnection({iceServers:[]});
</span><del>- var sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
</del><ins>+ var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
</ins><span class="cx"> shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, requestFailed1);');
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionstableexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable-expected.txt (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable-expected.txt        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+Tests RTCPeerConnection in stable state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is "InvalidSessionDescriptionError"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is "offer"
+PASS pc.localDescription.sdp is "local"
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "have-local-offer"
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is "stable"
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is "offer"
+PASS pc.remoteDescription.sdp is "remote"
+PASS pc.signalingState is "have-remote-offer"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionstablehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable.html (0 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable.html         (rev 0)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stable.html        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description("Tests RTCPeerConnection in stable state.");
+
+ var pc = null;
+
+ function requestSucceeded2()
+ {
+ testPassed('setRemoteDescription succeeded.');
+ check("", "", "offer", "remote", '"have-remote-offer"');
+ finishJSTest();
+ }
+
+ function requestSucceeded1()
+ {
+ testPassed('setLocalDescription succeeded.');
+ check("offer", "local", "", "", '"have-local-offer"')
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+ }
+
+ function requestFailed4(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+ }
+
+ function requestFailed3(reason)
+ {
+ errorReason = reason;
+ testPassed('setRemoteDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+ }
+
+ function requestFailed2(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
+ shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+ }
+
+ function requestFailed1(reason)
+ {
+ errorReason = reason;
+ testPassed('setLocalDescription failed.');
+ shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
+ check("", "", "", "", '"stable"');
+ sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+ }
+
+ function finishIfSucceeded()
+ {
+ testFailed('setRemoteDescription succeeded.');
+ finishJSTest();
+ }
+
+ function finishIfFailed()
+ {
+ testFailed('setRemoteDescription failed.');
+ finishJSTest();
+ }
+
+ function check(localType, localSdp, remoteType, remoteSdp, signalingState)
+ {
+ if (localType !== "" && localSdp !== "") {
+ shouldBeEqualToString('pc.localDescription.type', localType);
+ shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+ } else {
+ shouldThrow('pc.localDescription');
+ }
+ if (remoteType !== "" && remoteSdp !== "") {
+ shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+ shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+ } else {
+ shouldThrow('pc.remoteDescription');
+ }
+ shouldBe('pc.signalingState', signalingState);
+ }
+
+ pc = new webkitRTCPeerConnection({iceServers:[]});
+ shouldBe('pc.signalingState', '"stable"');
+ var sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
+ shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/ChangeLog        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2013-12-16 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org>
+
+ Checking RTCPeerConnection signalingState before setting local/remoteDescription
+ https://bugs.webkit.org/show_bug.cgi?id=125655
+
+ Reviewed by Eric Carlson.
+
+ Before setting a session description RTCPeerConnection must check if it is in valid state for that SDP type.
+
+ New tests: fast/mediastream/RTCPeerConnection-have-local-answer.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-stable.html
+
+ Modified: fast/mediastream/RTCPeerConnection-remoteDescription.html
+
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::checkStateForLocalDescription): Checks if the current state of RTCPeerConnection is
+ valid for the local SDP that is being set.
+ (WebCore::RTCPeerConnection::checkStateForRemoteDescription): Checks if the current state of RTCPeerConnection
+ is valid for the remote SDP that is being set.
+ (WebCore::RTCPeerConnection::setLocalDescription): Now calls checkStateForLocalDescription prior to set the
+ local SDP.
+ (WebCore::RTCPeerConnection::setRemoteDescription): Now Calls checkStateForRemoteDescription prior to set the
+ remote SDP.
+ * Modules/mediastream/RTCPeerConnection.h:
+ * platform/mock/RTCNotifiersMock.cpp: Adding new class to notify RTCPeerConnection about a signaling state
+ change: SignalingStateNotifier.
+ (WebCore::SignalingStateNotifier::SignalingStateNotifier):
+ (WebCore::SignalingStateNotifier::fire):
+ * platform/mock/RTCNotifiersMock.h:
+ * platform/mock/RTCPeerConnectionHandlerMock.cpp:
+ (WebCore::RTCPeerConnectionHandlerMock::signalingStateFromSDP): Defines the new state that RTCPeerConnection
+ should be, according the SDP that is being set.
+ (WebCore::RTCPeerConnectionHandlerMock::setLocalDescription): Calls signalingStateFromSDP, in order to get the
+ new signaling state and notify RTCPeerConnection object.
+ (WebCore::RTCPeerConnectionHandlerMock::setRemoteDescription): Ditto.
+ * platform/mock/RTCPeerConnectionHandlerMock.h:
+
</ins><span class="cx"> 2013-12-16 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Revert a mysterious and inexplicable part of http://trac.webkit.org/changeset/160685
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCPeerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -62,6 +62,8 @@
</span><span class="cx"> #include "RTCVoidRequestImpl.h"
</span><span class="cx"> #include "ScriptExecutionContext.h"
</span><span class="cx"> #include "VoidCallback.h"
</span><ins>+#include <wtf/Functional.h>
+#include <wtf/MainThread.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -210,6 +212,30 @@
</span><span class="cx"> m_peerHandler->createAnswer(request.release(), constraints.release());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool RTCPeerConnection::checkStateForLocalDescription(RTCSessionDescription* localDescription)
+{
+ if (localDescription->type() == "offer")
+ return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveLocalOffer;
+ if (localDescription->type() == "answer")
+ return m_signalingState == SignalingStateHaveRemoteOffer || m_signalingState == SignalingStateHaveLocalPrAnswer;
+ if (localDescription->type() == "pranswer")
+ return m_signalingState == SignalingStateHaveLocalPrAnswer || m_signalingState == SignalingStateHaveRemoteOffer;
+
+ return false;
+}
+
+bool RTCPeerConnection::checkStateForRemoteDescription(RTCSessionDescription* remoteDescription)
+{
+ if (remoteDescription->type() == "offer")
+ return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveRemoteOffer;
+ if (remoteDescription->type() == "answer")
+ return m_signalingState == SignalingStateHaveLocalOffer || m_signalingState == SignalingStateHaveRemotePrAnswer;
+ if (remoteDescription->type() == "pranswer")
+ return m_signalingState == SignalingStateHaveRemotePrAnswer || m_signalingState == SignalingStateHaveLocalOffer;
+
+ return false;
+}
+
</ins><span class="cx"> void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> prpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> if (m_signalingState == SignalingStateClosed) {
</span><span class="lines">@@ -223,6 +249,12 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (!checkStateForLocalDescription(sessionDescription.get())) {
+ RefPtr<DOMError> error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName());
+ callOnMainThread(bind(&RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release()));
+ return;
+ }
+
</ins><span class="cx"> RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
</span><span class="cx"> m_peerHandler->setLocalDescription(request.release(), sessionDescription->descriptor());
</span><span class="cx"> }
</span><span class="lines">@@ -252,6 +284,12 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (!checkStateForRemoteDescription(sessionDescription.get())) {
+ RefPtr<DOMError> error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName());
+ callOnMainThread(bind(&RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release()));
+ return;
+ }
+
</ins><span class="cx"> RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
</span><span class="cx"> m_peerHandler->setRemoteDescription(request.release(), sessionDescription->descriptor());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCPeerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -149,6 +149,9 @@
</span><span class="cx"> void changeIceGatheringState(IceGatheringState);
</span><span class="cx"> void changeIceConnectionState(IceConnectionState);
</span><span class="cx">
</span><ins>+ bool checkStateForLocalDescription(RTCSessionDescription*);
+ bool checkStateForRemoteDescription(RTCSessionDescription*);
+
</ins><span class="cx"> SignalingState m_signalingState;
</span><span class="cx"> IceGatheringState m_iceGatheringState;
</span><span class="cx"> IceConnectionState m_iceConnectionState;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCNotifiersMockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -80,6 +80,17 @@
</span><span class="cx"> m_client->didChangeIceConnectionState(m_connectionState);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SignalingStateNotifier::SignalingStateNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::SignalingState signalingState)
+ : m_client(client)
+ , m_signalingState(signalingState)
+{
+}
+
+void SignalingStateNotifier::fire()
+{
+ m_client->didChangeSignalingState(m_signalingState);
+}
+
</ins><span class="cx"> RemoteDataChannelNotifier::RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient* client)
</span><span class="cx"> : m_client(client)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCNotifiersMockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -77,6 +77,17 @@
</span><span class="cx"> RTCPeerConnectionHandlerClient::IceGatheringState m_gatheringState;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+class SignalingStateNotifier : public MockNotifier {
+public:
+ SignalingStateNotifier(RTCPeerConnectionHandlerClient*, RTCPeerConnectionHandlerClient::SignalingState);
+
+ void fire() OVERRIDE;
+
+private:
+ RTCPeerConnectionHandlerClient* m_client;
+ RTCPeerConnectionHandlerClient::SignalingState m_signalingState;
+};
+
</ins><span class="cx"> class RemoteDataChannelNotifier : public MockNotifier {
</span><span class="cx"> public:
</span><span class="cx"> RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient*);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCPeerConnectionHandlerMockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -87,30 +87,50 @@
</span><span class="cx"> m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RTCPeerConnectionHandlerClient::SignalingState RTCPeerConnectionHandlerMock::signalingStateFromSDP(RTCSessionDescriptionDescriptor* descriptor)
+{
+ if (descriptor->type() == "offer" && descriptor->sdp() == "local")
+ return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer;
+ if (descriptor->type() == "offer" && descriptor->sdp() == "remote")
+ return RTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer;
+ if (descriptor->type() == "pranswer" && descriptor->sdp() == "local")
+ return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer;
+ if (descriptor->type() == "pranswer" && descriptor->sdp() == "remote")
+ return RTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer;
+
+ return RTCPeerConnectionHandlerClient::SignalingStateStable;
+}
+
</ins><span class="cx"> void RTCPeerConnectionHandlerMock::setLocalDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor)
</span><span class="cx"> {
</span><del>- RefPtr<VoidRequestNotifier> notifier;
</del><ins>+ RefPtr<VoidRequestNotifier> voidNotifier;
+ RefPtr<SignalingStateNotifier> signalingNotifier;
</ins><span class="cx"> if (!descriptor.get() || descriptor->sdp() != "local")
</span><del>- notifier = adoptRef(new VoidRequestNotifier(request, false));
</del><ins>+ voidNotifier = adoptRef(new VoidRequestNotifier(request, false, RTCPeerConnectionHandler::internalErrorName()));
</ins><span class="cx"> else {
</span><span class="cx"> m_localSessionDescription = descriptor;
</span><del>- notifier = adoptRef(new VoidRequestNotifier(request, true));
</del><ins>+ signalingNotifier = adoptRef(new SignalingStateNotifier(m_client, signalingStateFromSDP(m_localSessionDescription.get())));
+ voidNotifier = adoptRef(new VoidRequestNotifier(request, true));
+ m_timerEvents.append(adoptRef(new TimerEvent(this, signalingNotifier)));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
</del><ins>+ m_timerEvents.append(adoptRef(new TimerEvent(this, voidNotifier)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void RTCPeerConnectionHandlerMock::setRemoteDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor)
</span><span class="cx"> {
</span><del>- RefPtr<VoidRequestNotifier> notifier;
</del><ins>+ RefPtr<VoidRequestNotifier> voidNotifier;
+ RefPtr<SignalingStateNotifier> signalingNotifier;
</ins><span class="cx"> if (!descriptor.get() || descriptor->sdp() != "remote")
</span><del>- notifier = adoptRef(new VoidRequestNotifier(request, false));
</del><ins>+ voidNotifier = adoptRef(new VoidRequestNotifier(request, false, RTCPeerConnectionHandler::internalErrorName()));
</ins><span class="cx"> else {
</span><span class="cx"> m_remoteSessionDescription = descriptor;
</span><del>- notifier = adoptRef(new VoidRequestNotifier(request, true));
</del><ins>+ signalingNotifier = adoptRef(new SignalingStateNotifier(m_client, signalingStateFromSDP(m_remoteSessionDescription.get())));
+ voidNotifier = adoptRef(new VoidRequestNotifier(request, true));
+ m_timerEvents.append(adoptRef(new TimerEvent(this, signalingNotifier)));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
</del><ins>+ m_timerEvents.append(adoptRef(new TimerEvent(this, voidNotifier)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<RTCSessionDescriptionDescriptor> RTCPeerConnectionHandlerMock::localDescription()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCPeerConnectionHandlerMockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h (160692 => 160693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h        2013-12-17 03:48:05 UTC (rev 160692)
+++ trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h        2013-12-17 04:12:19 UTC (rev 160693)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">
</span><span class="cx"> #include "RTCPeerConnectionHandler.h"
</span><ins>+#include "RTCPeerConnectionHandlerClient.h"
</ins><span class="cx"> #include "RTCSessionDescriptionDescriptor.h"
</span><span class="cx"> #include "TimerEventBasedMock.h"
</span><span class="cx">
</span><span class="lines">@@ -60,6 +61,7 @@
</span><span class="cx"> explicit RTCPeerConnectionHandlerMock(RTCPeerConnectionHandlerClient*);
</span><span class="cx">
</span><span class="cx"> private:
</span><ins>+ RTCPeerConnectionHandlerClient::SignalingState signalingStateFromSDP(RTCSessionDescriptionDescriptor*);
</ins><span class="cx"> RTCPeerConnectionHandlerClient* m_client;
</span><span class="cx">
</span><span class="cx"> RefPtr<RTCSessionDescriptionDescriptor> m_localSessionDescription;
</span></span></pre>
</div>
</div>
</body>
</html>