summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /testing/web-platform/tests/webrtc
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc')
-rw-r--r--testing/web-platform/tests/webrtc/RTCDataChannel-send-close.html123
-rw-r--r--testing/web-platform/tests/webrtc/RTCIceCandidate-constructor.html10
-rw-r--r--testing/web-platform/tests/webrtc/RTCPeerConnection-GC.https.html30
-rw-r--r--testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html95
-rw-r--r--testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js14
-rw-r--r--testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js2
6 files changed, 268 insertions, 6 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCDataChannel-send-close.html b/testing/web-platform/tests/webrtc/RTCDataChannel-send-close.html
new file mode 100644
index 0000000000..1bcc96790d
--- /dev/null
+++ b/testing/web-platform/tests/webrtc/RTCDataChannel-send-close.html
@@ -0,0 +1,123 @@
+<!doctype html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>RTCDataChannel.prototype.send</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="RTCPeerConnection-helper.js"></script>
+<script>
+'use strict';
+
+const largeString = " ".repeat(64 * 1024);
+const largeArrayBuffer = new TextEncoder("utf-8").encode(largeString);
+const largeBlob = new Blob([" ".repeat(64 * 1024)]);
+
+for (const options of [{}, {negotiated: true, id: 0}]) {
+ const mode = `${options.negotiated? "Negotiated d" : "D"}atachannel`;
+
+ promise_test(async t => {
+ let [channel1, channel2] = await createDataChannelPair(t, options);
+ let receivedSize = 0, sentSize = 0;
+
+ channel2.binaryType = 'arraybuffer';
+ channel2.onmessage = e => {
+ if (typeof e.data === 'string')
+ receivedSize += e.data.length;
+ else
+ receivedSize += e.data.byteLength;
+ }
+
+ let closePromiseResolve;
+ let closePromise = new Promise((resolve, reject) => {
+ closePromiseResolve = resolve;
+ });
+ channel2.onclose = e => {
+ closePromiseResolve();
+ }
+
+ try {
+ while(true) {
+ channel1.send(largeString);
+ sentSize += largeString.length;
+ }
+ } catch(error) {
+ assert_true(error instanceof DOMException);
+ assert_equals(error.name, 'OperationError');
+ }
+ channel1.close();
+
+ await closePromise;
+ assert_equals(receivedSize, sentSize, 'All the pending sent messages are received after calling close()');
+ }, `${mode} should be able to send and receive all string messages on close`);
+
+ promise_test(async t => {
+ let [channel1, channel2] = await createDataChannelPair(t, options);
+ let receivedSize = 0, sentSize = 0;
+
+ channel2.binaryType = 'arraybuffer';
+ channel2.onmessage = e => {
+ if (typeof e.data === 'string')
+ receivedSize += e.data.length;
+ else
+ receivedSize += e.data.byteLength;
+ }
+
+ let closePromiseResolve;
+ let closePromise = new Promise((resolve, reject) => {
+ closePromiseResolve = resolve;
+ });
+ channel2.onclose = e => {
+ closePromiseResolve();
+ }
+
+ try {
+ while(true) {
+ channel1.send(largeArrayBuffer);
+ sentSize += largeArrayBuffer.length;
+ }
+ } catch(error) {
+ assert_true(error instanceof DOMException);
+ assert_equals(error.name, 'OperationError');
+ }
+ channel1.close();
+
+ await closePromise;
+ assert_equals(receivedSize, sentSize, 'All the pending sent messages are received after calling close()');
+ }, `${mode} should be able to send and receive all arraybuffer messages on close`);
+
+ promise_test(async t => {
+ let [channel1, channel2] = await createDataChannelPair(t, options);
+ let receivedSize = 0, sentSize = 0;
+
+ channel2.binaryType = 'arraybuffer';
+ channel2.onmessage = e => {
+ if (typeof e.data === 'string')
+ receivedSize += e.data.length;
+ else
+ receivedSize += e.data.byteLength;
+ }
+
+ let closePromiseResolve;
+ let closePromise = new Promise((resolve, reject) => {
+ closePromiseResolve = resolve;
+ });
+ channel2.onclose = e => {
+ closePromiseResolve();
+ }
+
+ try {
+ while(true) {
+ channel1.send(largeBlob);
+ sentSize += largeBlob.size;
+ }
+ } catch(error) {
+ assert_true(error instanceof DOMException);
+ assert_equals(error.name, 'OperationError');
+ }
+ channel1.close();
+
+ await closePromise;
+ assert_equals(receivedSize, sentSize, 'All the pending sent messages are received after calling close()');
+ }, `${mode} should be able to send and receive all blob messages on close`);
+}
+</script>
diff --git a/testing/web-platform/tests/webrtc/RTCIceCandidate-constructor.html b/testing/web-platform/tests/webrtc/RTCIceCandidate-constructor.html
index 66d6962079..b760c7b05a 100644
--- a/testing/web-platform/tests/webrtc/RTCIceCandidate-constructor.html
+++ b/testing/web-platform/tests/webrtc/RTCIceCandidate-constructor.html
@@ -57,7 +57,7 @@
}, `new RTCIceCandidate({ candidate: '' })`);
test(t => {
- // Throws because the candidate field is not nullable
+ // Throws because both sdpMid and sdpMLineIndex are null by default
assert_throws_js(TypeError,
() => new RTCIceCandidate({
candidate: null
@@ -116,15 +116,15 @@
test(t => {
const candidate = new RTCIceCandidate({
- candidate: '',
+ candidate: null,
sdpMLineIndex: 0
});
- assert_equals(candidate.candidate, '', 'candidate');
+ assert_equals(candidate.candidate, 'null', 'candidate');
assert_equals(candidate.sdpMid, null, 'sdpMid', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 0, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
- }, `new RTCIceCandidate({ candidate: '', sdpMLineIndex: 0 }`);
+ }, `new RTCIceCandidate({ candidate: null, sdpMLineIndex: 0 }`);
test(t => {
const candidate = new RTCIceCandidate({
@@ -138,7 +138,7 @@
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with valid candidate string and sdpMid');
- test(t =>{
+ test(t => {
// candidate string is not validated in RTCIceCandidate
const candidate = new RTCIceCandidate({
candidate: arbitraryString,
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-GC.https.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-GC.https.html
index 156a2e1f09..282c362a2d 100644
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-GC.https.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-GC.https.html
@@ -85,6 +85,36 @@ promise_test(async t => {
await onVideoChange();
assert_not_equals(color, getVideoSignal(destVideo));
}, "GC does not collect a peer connection pipe rendering to a video element");
+
+promise_test(async t => {
+ const pc1 = new RTCPeerConnection();
+ t.add_cleanup(() => pc1.close());
+ const pc2 = new RTCPeerConnection();
+ t.add_cleanup(() => pc2.close());
+
+ const [track, stream] = await createTrackAndStreamWithCleanup(t, "video");
+ pc1.addTrack(track, stream);
+ exchangeIceCandidates(pc1, pc2);
+
+ const metadataToBeLoaded = [];
+ pc2.ontrack = (e) => {
+ const stream = e.streams[0];
+ const v = document.createElement('video');
+ v.autoplay = true;
+ v.srcObject = stream;
+ v.id = stream.id
+ metadataToBeLoaded.push(new Promise((resolve) => {
+ v.addEventListener('loadedmetadata', () => {
+ resolve();
+ });
+ }));
+ };
+ await exchangeOfferAnswer(pc1, pc2);
+
+ garbageCollect();
+
+ await Promise.all(metadataToBeLoaded);
+}, "GC does not collect an HTMLMediaElement playing a video track");
</script>
</body>
</html>
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
new file mode 100644
index 0000000000..1e7fc3ba95
--- /dev/null
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
@@ -0,0 +1,95 @@
+<!doctype html>
+<title>Test RTCPeerConnection.prototype.addIceCandidate with TCP candidates</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="RTCPeerConnection-helper.js"></script>
+<script>
+'use strict';
+
+const sdp = `v=0
+o=- 166855176514521964 2 IN IP4 127.0.0.1
+s=-
+t=0 0
+a=msid-semantic:WMS *
+m=audio 9 UDP/TLS/RTP/SAVPF 111
+c=IN IP4 0.0.0.0
+a=rtcp:9 IN IP4 0.0.0.0
+a=ice-ufrag:655Y
+a=ice-pwd:somelongpwdwithenoughrandomness
+a=fingerprint:sha-256 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
+a=setup:actpass
+a=mid:audio1
+a=sendonly
+a=rtcp-mux
+a=rtcp-rsize
+a=rtpmap:111 opus/48000/2
+a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
+a=ssrc:1001 cname:some
+`;
+
+const candidate_8001 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 8001 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+const candidate_2049 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 2049 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+const candidate_37 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 37 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_8001 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await waitForConnectionStateChangeWithTimeout(t, pc,
+ ['failed', 'disconnected'], 1000);
+}, 'TCP candidate aimed at port 8001 accepted');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_2049 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP candidate aimed at port 2049 ignored');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_37 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP candidate aimed at port 37 ignored');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await pc.addIceCandidate(new RTCIceCandidate({
+ candidate: candidate_8001,
+ sdpMid: 'audio1'
+ }));
+ await waitForConnectionStateChangeWithTimeout(
+ t, pc, ['failed', 'disconnected'], 1000);
+}, 'TCP addIceCandidate aimed at port 8001 accepted');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await pc.addIceCandidate(new RTCIceCandidate({
+ candidate: candidate_2049,
+ sdpMid: 'audio1'
+ }));
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP addIceCandidate aimed at port 2049 ignored');
+
+
+</script>
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js b/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js
index 6f35fde76c..cd27b033d3 100644
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js
@@ -230,6 +230,20 @@ async function waitForConnectionStateChange(pc, wantedStates) {
}
}
+function waitForConnectionStateChangeWithTimeout(t, pc, wantedStates, timeout) {
+ return new Promise((resolve, reject) => {
+ if (wantedStates.includes(pc.connectionState)) {
+ resolve();
+ return;
+ }
+ pc.addEventListener('connectionstatechange', () => {
+ if (wantedStates.includes(pc.connectionState))
+ resolve();
+ });
+ t.step_timeout(reject, timeout);
+ });
+}
+
async function waitForIceGatheringState(pc, wantedStates) {
while (!wantedStates.includes(pc.iceGatheringState)) {
await waitUntilEvent(pc, 'icegatheringstatechange');
diff --git a/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js b/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js
index 5cc3b745b3..fe41a9cfd5 100644
--- a/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js
+++ b/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js
@@ -16,5 +16,5 @@ promise_test(async t => {
await openWebRTC(rc1);
// The page should not be eligible for BFCache because of open WebRTC connection and live MediaStreamTrack.
await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false);
- await assertNotRestoredFromBFCache(rc1, ['webrtc', 'media-stream']);
+ await assertNotRestoredFromBFCache(rc1, ['rtc', 'mediastream']);
});