| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests RTCPeerConnection createAnswer."); |
| |
| var pc = null; |
| |
| function unexpectedCallback() |
| { |
| testFailed('unexpectedCallback was called') |
| finishJSTest(); |
| } |
| |
| function answerCreated() |
| { |
| testPassed('createAnswer request succeeded.'); |
| finishJSTest(); |
| } |
| |
| function descriptionSet() |
| { |
| testPassed('setRemoteDescription request succeeded.'); |
| shouldNotThrow('pc.createAnswer(answerCreated, unexpectedCallback);'); |
| } |
| |
| function createOfferWithoutDescriptionFailed() |
| { |
| testPassed('createOffer request without remote description failed.'); |
| sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"}); |
| shouldNotThrow('pc.setRemoteDescription(sessionDescription, descriptionSet, unexpectedCallback);'); |
| } |
| |
| function testExecutionOrderClosedConnection() |
| { |
| var localPeerConnection = new RTCPeerConnection(); |
| localPeerConnection.close(); |
| var counter = 0; |
| window.events = []; |
| Promise.resolve().then(_ => window.events[counter++] = 1); |
| localPeerConnection.createAnswer(unexpectedCallback, error => { |
| window.error = error; |
| shouldBe('error.name', '"InvalidStateError"'); |
| shouldBe('error.toString()', '"InvalidStateError: The RTCPeerConnection\'s signalingState is \'closed\'."'); |
| window.events[counter++] = 2; |
| }); |
| Promise.resolve().then(_ => { |
| window.events[counter++] = 3; |
| shouldBe('events', '[1,2,3]'); |
| }); |
| } |
| |
| shouldNotThrow('testExecutionOrderClosedConnection()'); |
| pc = new RTCPeerConnection(); |
| pc.createOffer(unexpectedCallback, createOfferWithoutDescriptionFailed); |
| |
| window.jsTestIsAsync = true; |
| window.successfullyParsed = true; |
| </script> |
| </body> |
| </html> |