Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WebRTC: Test that RTCPeerConnection promise functions reject on close…
…d state https://bugs.webkit.org/show_bug.cgi?id=152295 Reviewed by Eric Carlson. Add test that verifies RTCPeerConnection's behavior in the closed state (signalingState). Promise functions should reject, and (some) others should throw. Remove old test that tests incorrect behavior. * fast/mediastream/RTCPeerConnection-closed-state-expected.txt: Added. * fast/mediastream/RTCPeerConnection-closed-state.html: Added. * fast/mediastream/RTCPeerConnection-state-expected.txt: Removed. * fast/mediastream/RTCPeerConnection-state.html: Removed. Canonical link: https://commits.webkit.org/170417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194112 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
163 additions
and 42 deletions.
- +16 −0 LayoutTests/ChangeLog
- +43 −0 LayoutTests/fast/mediastream/RTCPeerConnection-closed-state-expected.txt
- +104 −0 LayoutTests/fast/mediastream/RTCPeerConnection-closed-state.html
- +0 −13 LayoutTests/fast/mediastream/RTCPeerConnection-state-expected.txt
- +0 −29 LayoutTests/fast/mediastream/RTCPeerConnection-state.html
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,43 @@ | ||
Test calling RTCPeerConnection functions/attributes in closed state | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS pc = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); did not throw exception. | ||
PASS pc.signalingState is "stable" | ||
Get a sender before closing (to test removeTrack later) | ||
PASS sender = pc.addTrack(stream.getTracks()[0], stream) did not throw exception. | ||
|
||
Test promise-returning functions | ||
PASS createOffer rejected on closed state | ||
PASS createAnswer rejected on closed state | ||
PASS setLocalDescription rejected on closed state | ||
PASS setRemoteDescription rejected on closed state | ||
PASS addIceCandidate rejected on closed state | ||
PASS getStats rejected on closed state | ||
|
||
Test non-promise functions | ||
PASS pc.addTrack(stream.getTracks()[0], stream) threw exception Error: InvalidStateError: DOM Exception 11. | ||
PASS pc.removeTrack(sender) threw exception Error: InvalidStateError: DOM Exception 11. | ||
PASS pc.getSenders() did not throw exception. | ||
PASS pc.getReceivers() did not throw exception. | ||
PASS pc.getConfiguration() did not throw exception. | ||
PASS pc.setConfiguration({}) threw exception Error: InvalidStateError: DOM Exception 11. | ||
PASS pc.createDataChannel("foo") threw exception Error: InvalidStateError: DOM Exception 11. | ||
PASS pc.close() did not throw exception. | ||
|
||
Test attributes | ||
PASS pc.localDescription did not throw exception. | ||
PASS pc.currentLocalDescription did not throw exception. | ||
PASS pc.pendingLocalDescription did not throw exception. | ||
PASS pc.remoteDescription did not throw exception. | ||
PASS pc.currentRemoteDescription did not throw exception. | ||
PASS pc.pendingRemoteDescription did not throw exception. | ||
PASS pc.signalingState did not throw exception. | ||
PASS pc.iceGatheringState did not throw exception. | ||
PASS pc.iceConnectionState did not throw exception. | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,104 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Test calling RTCPeerConnection functions/attributes in closed state"); | ||
|
||
if (window.testRunner) | ||
testRunner.setUserMediaPermission(true); | ||
else { | ||
debug("This test can not be run without the testRunner"); | ||
finishJSTest(); | ||
} | ||
|
||
var pc; | ||
var stream; | ||
var sender; | ||
|
||
shouldNotThrow("pc = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});"); | ||
shouldBeEqualToString('pc.signalingState', 'stable'); | ||
|
||
var desc = new RTCSessionDescription({ "type": "offer" }); | ||
var candidate = new RTCIceCandidate({ "sdpMLineIndex": 0 }); | ||
|
||
navigator.mediaDevices.getUserMedia({ "video": true }).then(function (s) { | ||
stream = s; | ||
debug("Get a sender before closing (to test removeTrack later)"); | ||
shouldNotThrow('sender = pc.addTrack(stream.getTracks()[0], stream)'); | ||
debug(""); | ||
|
||
pc.close(); | ||
debug("Test promise-returning functions"); | ||
return pc.createOffer(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("createOffer rejected on closed state"); | ||
return pc.createAnswer(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("createAnswer rejected on closed state"); | ||
return pc.setLocalDescription(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("setLocalDescription rejected on closed state"); | ||
return pc.setRemoteDescription(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("setRemoteDescription rejected on closed state"); | ||
return pc.addIceCandidate(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("addIceCandidate rejected on closed state"); | ||
return pc.getStats(); | ||
}) | ||
.then(failed, function () { | ||
testPassed("getStats rejected on closed state"); | ||
debug(""); | ||
testNonPromise() | ||
}) | ||
.catch(function (e) { | ||
testFailed("Error caught in promise chain: " + e); | ||
finishJSTest(); | ||
}); | ||
|
||
function testNonPromise() { | ||
debug("Test non-promise functions"); | ||
shouldThrow('pc.addTrack(stream.getTracks()[0], stream)'); | ||
shouldThrow('pc.removeTrack(sender)'); | ||
shouldNotThrow('pc.getSenders()'); | ||
shouldNotThrow('pc.getReceivers()'); | ||
shouldNotThrow('pc.getConfiguration()'); | ||
shouldThrow('pc.setConfiguration({})'); | ||
shouldThrow('pc.createDataChannel("foo")'); | ||
shouldNotThrow('pc.close()'); | ||
debug(""); | ||
|
||
debug("Test attributes"); | ||
shouldNotThrow("pc.localDescription"); | ||
shouldNotThrow("pc.currentLocalDescription"); | ||
shouldNotThrow("pc.pendingLocalDescription"); | ||
shouldNotThrow("pc.remoteDescription"); | ||
shouldNotThrow("pc.currentRemoteDescription"); | ||
shouldNotThrow("pc.pendingRemoteDescription"); | ||
shouldNotThrow("pc.signalingState"); | ||
shouldNotThrow("pc.iceGatheringState"); | ||
shouldNotThrow("pc.iceConnectionState"); | ||
debug(""); | ||
|
||
finishJSTest(); | ||
} | ||
|
||
function failed() { | ||
testFailed("Function should have rejected on closed state"); | ||
finishJSTest(); | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
window.successfullyParsed = true; | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |