| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests RTCPeerConnection createOffer."); |
| |
| // Let's ensure built-ins are shielded from user scripts |
| var thenPromise = Promise.prototype.then; |
| Promise.prototype.then = function() { |
| console.log("Promise.prototype.then is called internally"); |
| return thenPromise.apply(this, arguments); |
| } |
| |
| var pc = null; |
| |
| function requestSucceeded3(sd) |
| { |
| testPassed('createOffer request succeeded.'); |
| |
| sessionDescription = sd; |
| shouldBe('sessionDescription.type', '"offer"'); |
| finishJSTest(); |
| } |
| |
| function requestFailed7(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldNotThrow('pc.createOffer(requestSucceeded3, requestFailed1, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:0});'); |
| } |
| |
| function requestFailed6(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed7, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:""});'); |
| } |
| |
| function requestFailed5(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed6, {requestIdentity:"yes", offerToReceiveVideo:"", offerToReceiveAudio:0});'); |
| } |
| |
| function requestFailed4(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed5, {offerToReceiveVideo:0, offerToReceiveAudio:0});'); |
| } |
| |
| function requestFailed3(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed4, {requestIdentity:"yes", offerToReceiveVideo:0});'); |
| } |
| |
| function requestFailed2(reason) |
| { |
| testPassed('createOffer request failed.'); |
| |
| errorReason = reason; |
| shouldBe('errorReason.name', '"Invalid createOffer argument."'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed3, {requestIdentity:"yes", offerToReceiveAudio:0});'); |
| } |
| |
| function requestSucceeded2(sd) |
| { |
| testFailed('createOffer request succeeded.'); |
| finishJSTest(); |
| } |
| |
| function requestFailed1() |
| { |
| testFailed('createOffer request failed.'); |
| finishJSTest(); |
| } |
| |
| function requestSucceeded1(sd) |
| { |
| testPassed('createOffer request succeeded.'); |
| |
| sessionDescription = sd; |
| shouldBe('sessionDescription.type', '"offer"'); |
| |
| shouldThrow('pc.createOffer(requestSucceeded2, requestFailed2, {});'); |
| } |
| |
| pc = new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); |
| shouldNotThrow('pc.createOffer(requestSucceeded1, requestFailed1);'); |
| |
| window.jsTestIsAsync = true; |
| window.successfullyParsed = true; |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |