Truly independent web browser
LibWeb: Expose RTCSessionDescription.toJSON()
sideshowbarker163a356c3ae2
diff --git a/Libraries/LibWeb/WebRTC/RTCSessionDescription.idl b/Libraries/LibWeb/WebRTC/RTCSessionDescription.idlindex f3909d1a4db..4d491c6a720 100644--- a/Libraries/LibWeb/WebRTC/RTCSessionDescription.idl+++ b/Libraries/LibWeb/WebRTC/RTCSessionDescription.idl@@ -12,7 +12,7 @@ interface RTCSessionDescription {constructor(RTCSessionDescriptionInit descriptionInitDict);readonly attribute RTCSdpType type;readonly attribute DOMString sdp;- [FIXME] RTCSessionDescriptionInit toJSON();+ RTCSessionDescriptionInit toJSON();};dictionary RTCSessionDescriptionInit {diff --git a/Tests/LibWeb/Text/expected/wpt-import/webrtc/toJSON.txt b/Tests/LibWeb/Text/expected/wpt-import/webrtc/toJSON.txtnew file mode 100644index 00000000000..b11acea1b70--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/webrtc/toJSON.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Pass+Pass RTCSessionDescription.toJSON serializes only specific attributes+Pass RTCIceCandidate.toJSON serializes only specific attributes\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/webrtc/toJSON.html b/Tests/LibWeb/Text/input/wpt-import/webrtc/toJSON.htmlnew file mode 100644index 00000000000..3ea922197a6--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/webrtc/toJSON.html@@ -0,0 +1,51 @@+<!doctype html>+<meta charset=utf-8>+<title>WebRTC objects toJSON() methods</title>+<script src=../resources/testharness.js></script>+<script src=../resources/testharnessreport.js></script>+<script>+'use strict';+// The tests for+// * RTCSessionDescription.toJSON()+// * RTCIceCandidate.toJSON()+// are kept in a single file since they are similar and typically+// would need to be changed together.++test(t => {+ const desc = new RTCSessionDescription({+ type: 'offer',+ sdp: 'bogus sdp',+ });+ const json = desc.toJSON();++ // Assert that candidates which should be serialized are present.+ assert_equals(json.type, desc.type);+ assert_equals(json.sdp, desc.sdp);++ // Assert that no other attributes are present by checking the size.+ assert_equals(Object.keys(json).length, 2);++}, 'RTCSessionDescription.toJSON serializes only specific attributes');++test(t => {+ const candidate = new RTCIceCandidate({+ sdpMLineIndex: 0,+ sdpMid: '0',+ candidate: 'candidate:1905690388 1 udp 2113937151 192.168.0.1 58041 typ host',+ usernameFragment: 'test'+ });+ const json = candidate.toJSON();++ // Assert that candidates which should be serialized are present.+ assert_equals(json.sdpMLineIndex, candidate.sdpMLineIndex);+ assert_equals(json.sdpMid, candidate.sdpMid);+ assert_equals(json.candidate, candidate.candidate);+ assert_equals(json.usernameFragment, candidate.usernameFragment);++ // Assert that no other attributes are present by checking the size.+ assert_equals(Object.keys(json).length, 4);++}, 'RTCIceCandidate.toJSON serializes only specific attributes');+++</script>