<!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  &lt;thiago.lacerda@openbossa.org&gt;
+
+        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  &lt;oliver@apple.com&gt;
</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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection remoteDescription.&quot;);
+
+            var pc = null;
+
+            function requestFailed4(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                finishJSTest();
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+            }
+
+            function requestSucceeded2()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;answer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+                    shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+                }
+                shouldBe('pc.signalingState', signalingState);
+            }
+
+            pc = new webkitRTCPeerConnection({iceServers:[]});
+            shouldBe('pc.signalingState', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+            shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded5, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;answer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;stable&quot;
+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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection in have-local-offer state.&quot;);
+
+            var pc = null;
+
+            function requestSucceeded5()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;answer&quot;, &quot;remote&quot;, '&quot;stable&quot;');
+                finishJSTest();
+            }
+
+            function requestSucceeded4()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded5, finishIfFailed);');
+            }
+
+            function requestSucceeded3()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                pc = new webkitRTCPeerConnection({iceServers:[]});
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+            }
+
+            function requestSucceeded2()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                } else {
+                    shouldThrow('pc.localDescription');
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    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', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+            shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;answer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;stable&quot;
+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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection in have-local-pranswer state.&quot;);
+
+            var pc = null;
+
+            function requestSucceeded4()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;answer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;stable&quot;');
+                finishJSTest();
+            }
+
+            function requestFailed4(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+            }
+
+            function requestSucceeded3()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+            }
+
+            function requestSucceeded2()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+                    shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+                }
+                shouldBe('pc.signalingState', signalingState);
+            }
+
+            pc = new webkitRTCPeerConnection({iceServers:[]});
+            shouldBe('pc.signalingState', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+            shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pc.signalingState is &quot;stable&quot;
+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 &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+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 &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;answer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+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 &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded5, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;pranswer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-local-pranswer&quot;
+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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection in have-remote-offer state.&quot;);
+
+            var pc = null;
+
+            function requestSucceeded5()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;pranswer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-local-pranswer&quot;');
+                finishJSTest();
+            }
+
+            function requestSucceeded4()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded5, finishIfFailed);');
+            }
+
+            function requestSucceeded3()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;answer&quot;, &quot;local&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;stable&quot;');
+                pc = new webkitRTCPeerConnection({iceServers:[]});
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+            }
+
+            function requestSucceeded2()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                } else {
+                    shouldThrow('pc.localDescription');
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    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', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+            shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;pranswer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-pranswer&quot;
+PASS pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed); did not throw exception.
+PASS setRemoteDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription.type is &quot;answer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;stable&quot;
+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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection in have-remote-pranswer state.&quot;);
+
+            var pc = null;
+
+            function requestSucceeded4()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;answer&quot;, &quot;remote&quot;, '&quot;stable&quot;');
+                finishJSTest();
+            }
+
+            function requestFailed4(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
+            }
+
+            function requestSucceeded3()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+            }
+
+            function requestSucceeded2()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;pranswer&quot;, &quot;remote&quot;, '&quot;have-remote-pranswer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.remoteDescription.type', remoteType);
+                    shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
+                }
+                shouldBe('pc.signalingState', signalingState);
+            }
+
+            pc = new webkitRTCPeerConnection({iceServers:[]});
+            shouldBe('pc.signalingState', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+            shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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 &quot;answer&quot;
</del><ins>+PASS pc.remoteDescription.type is &quot;offer&quot;
</ins><span class="cx"> PASS pc.remoteDescription.sdp is &quot;remote&quot;
</span><del>-PASS pc.remoteDescription.type is &quot;answer&quot;
</del><ins>+PASS pc.remoteDescription.type is &quot;offer&quot;
</ins><span class="cx"> PASS pc.remoteDescription.sdp is &quot;remote&quot;
</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', &quot;answer&quot;);
</del><ins>+                shouldBeEqualToString('pc.remoteDescription.type', &quot;offer&quot;);
</ins><span class="cx">                 shouldBeEqualToString('pc.remoteDescription.sdp', &quot;remote&quot;);
</span><span class="cx">                 pc.close();
</span><del>-                shouldBeEqualToString('pc.remoteDescription.type', &quot;answer&quot;);
</del><ins>+                shouldBeEqualToString('pc.remoteDescription.type', &quot;offer&quot;);
</ins><span class="cx">                 shouldBeEqualToString('pc.remoteDescription.sdp', &quot;remote&quot;);
</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:&quot;offer&quot;, sdp:&quot;local&quot;});
</del><ins>+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
</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:&quot;answer&quot;, sdp:&quot;remote&quot;});
</del><ins>+            var sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2); did not throw exception.
+PASS setLocalDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4); did not throw exception.
+PASS setRemoteDescription failed.
+PASS errorReason.name is &quot;InvalidSessionDescriptionError&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+PASS pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed); did not throw exception.
+PASS setLocalDescription succeeded.
+PASS pc.localDescription.type is &quot;offer&quot;
+PASS pc.localDescription.sdp is &quot;local&quot;
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;have-local-offer&quot;
+PASS pc.localDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.remoteDescription threw exception Error: InvalidStateError: DOM Exception 11.
+PASS pc.signalingState is &quot;stable&quot;
+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 &quot;offer&quot;
+PASS pc.remoteDescription.sdp is &quot;remote&quot;
+PASS pc.signalingState is &quot;have-remote-offer&quot;
+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>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            description(&quot;Tests RTCPeerConnection in stable state.&quot;);
+
+            var pc = null;
+
+            function requestSucceeded2()
+            {
+                testPassed('setRemoteDescription succeeded.');
+                check(&quot;&quot;, &quot;&quot;, &quot;offer&quot;, &quot;remote&quot;, '&quot;have-remote-offer&quot;');
+                finishJSTest();
+            }
+
+            function requestSucceeded1()
+            {
+                testPassed('setLocalDescription succeeded.');
+                check(&quot;offer&quot;, &quot;local&quot;, &quot;&quot;, &quot;&quot;, '&quot;have-local-offer&quot;')
+                pc = new webkitRTCPeerConnection({iceServers:[]});
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
+            }
+
+            function requestFailed4(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;offer&quot;, sdp:&quot;local&quot;});
+                shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
+            }
+
+            function requestFailed3(reason)
+            {
+                errorReason = reason;
+                testPassed('setRemoteDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
+            }
+
+            function requestFailed2(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;remote&quot;});
+                shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
+            }
+
+            function requestFailed1(reason)
+            {
+                errorReason = reason;
+                testPassed('setLocalDescription failed.');
+                shouldBe('errorReason.name', '&quot;InvalidSessionDescriptionError&quot;');
+                check(&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, '&quot;stable&quot;');
+                sessionDescription = new RTCSessionDescription({type:&quot;pranswer&quot;, sdp:&quot;local&quot;});
+                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 !== &quot;&quot; &amp;&amp; localSdp !== &quot;&quot;) {
+                    shouldBeEqualToString('pc.localDescription.type', localType);
+                    shouldBeEqualToString('pc.localDescription.sdp', localSdp);
+                } else {
+                    shouldThrow('pc.localDescription');
+                }
+                if (remoteType !== &quot;&quot; &amp;&amp; remoteSdp !== &quot;&quot;) {
+                    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', '&quot;stable&quot;');
+            var sessionDescription = new RTCSessionDescription({type:&quot;answer&quot;, sdp:&quot;local&quot;});
+            shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        &lt;/script&gt;
+        &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</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  &lt;thiago.lacerda@openbossa.org&gt;
+
+        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  &lt;timothy_horton@apple.com&gt;
</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 &quot;RTCVoidRequestImpl.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><span class="cx"> #include &quot;VoidCallback.h&quot;
</span><ins>+#include &lt;wtf/Functional.h&gt;
+#include &lt;wtf/MainThread.h&gt;
</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-&gt;createAnswer(request.release(), constraints.release());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RTCPeerConnection::checkStateForLocalDescription(RTCSessionDescription* localDescription)
+{
+    if (localDescription-&gt;type() == &quot;offer&quot;)
+        return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveLocalOffer;
+    if (localDescription-&gt;type() == &quot;answer&quot;)
+        return m_signalingState == SignalingStateHaveRemoteOffer || m_signalingState == SignalingStateHaveLocalPrAnswer;
+    if (localDescription-&gt;type() == &quot;pranswer&quot;)
+        return m_signalingState == SignalingStateHaveLocalPrAnswer || m_signalingState == SignalingStateHaveRemoteOffer;
+
+    return false;
+}
+
+bool RTCPeerConnection::checkStateForRemoteDescription(RTCSessionDescription* remoteDescription)
+{
+    if (remoteDescription-&gt;type() == &quot;offer&quot;)
+        return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveRemoteOffer;
+    if (remoteDescription-&gt;type() == &quot;answer&quot;)
+        return m_signalingState == SignalingStateHaveLocalOffer || m_signalingState == SignalingStateHaveRemotePrAnswer;
+    if (remoteDescription-&gt;type() == &quot;pranswer&quot;)
+        return m_signalingState == SignalingStateHaveRemotePrAnswer || m_signalingState == SignalingStateHaveLocalOffer;
+
+    return false;
+}
+
</ins><span class="cx"> void RTCPeerConnection::setLocalDescription(PassRefPtr&lt;RTCSessionDescription&gt; prpSessionDescription, PassRefPtr&lt;VoidCallback&gt; successCallback, PassRefPtr&lt;RTCPeerConnectionErrorCallback&gt; errorCallback, ExceptionCode&amp; 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&lt;DOMError&gt; error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName());
+        callOnMainThread(bind(&amp;RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release()));
+        return;
+    }
+
</ins><span class="cx">     RefPtr&lt;RTCVoidRequestImpl&gt; request = RTCVoidRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
</span><span class="cx">     m_peerHandler-&gt;setLocalDescription(request.release(), sessionDescription-&gt;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&lt;DOMError&gt; error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName());
+        callOnMainThread(bind(&amp;RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release()));
+        return;
+    }
+
</ins><span class="cx">     RefPtr&lt;RTCVoidRequestImpl&gt; request = RTCVoidRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
</span><span class="cx">     m_peerHandler-&gt;setRemoteDescription(request.release(), sessionDescription-&gt;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-&gt;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-&gt;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-&gt;type() == &quot;offer&quot; &amp;&amp; descriptor-&gt;sdp() == &quot;local&quot;)
+        return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer;
+    if (descriptor-&gt;type() == &quot;offer&quot; &amp;&amp; descriptor-&gt;sdp() == &quot;remote&quot;)
+        return RTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer;
+    if (descriptor-&gt;type() == &quot;pranswer&quot; &amp;&amp; descriptor-&gt;sdp() == &quot;local&quot;)
+        return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer;
+    if (descriptor-&gt;type() == &quot;pranswer&quot; &amp;&amp; descriptor-&gt;sdp() == &quot;remote&quot;)
+        return RTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer;
+
+    return RTCPeerConnectionHandlerClient::SignalingStateStable;
+}
+
</ins><span class="cx"> void RTCPeerConnectionHandlerMock::setLocalDescription(PassRefPtr&lt;RTCVoidRequest&gt; request, PassRefPtr&lt;RTCSessionDescriptionDescriptor&gt; descriptor)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;VoidRequestNotifier&gt; notifier;
</del><ins>+    RefPtr&lt;VoidRequestNotifier&gt; voidNotifier;
+    RefPtr&lt;SignalingStateNotifier&gt; signalingNotifier;
</ins><span class="cx">     if (!descriptor.get() || descriptor-&gt;sdp() != &quot;local&quot;)
</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&lt;RTCVoidRequest&gt; request, PassRefPtr&lt;RTCSessionDescriptionDescriptor&gt; descriptor)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;VoidRequestNotifier&gt; notifier;
</del><ins>+    RefPtr&lt;VoidRequestNotifier&gt; voidNotifier;
+    RefPtr&lt;SignalingStateNotifier&gt; signalingNotifier;
</ins><span class="cx">     if (!descriptor.get() || descriptor-&gt;sdp() != &quot;remote&quot;)
</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&lt;RTCSessionDescriptionDescriptor&gt; 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 &quot;RTCPeerConnectionHandler.h&quot;
</span><ins>+#include &quot;RTCPeerConnectionHandlerClient.h&quot;
</ins><span class="cx"> #include &quot;RTCSessionDescriptionDescriptor.h&quot;
</span><span class="cx"> #include &quot;TimerEventBasedMock.h&quot;
</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&lt;RTCSessionDescriptionDescriptor&gt; m_localSessionDescription;
</span></span></pre>
</div>
</div>

</body>
</html>