Skip to content

Commit 18232b4

Browse files
Split RTCDataChannel-send-close.html web test to avoid timeouts (web-platform-tests#54772)
Addresses flakes by dividing the test into three new tests. Adds one test for each type of data sent: Blob, string, and ArrayBuffer. Adds `RTCDataChannel-send-close-helper.js` for shared test code. The original test ran for ~45 seconds on my powerful developer machine. Each new tests takes ~15 seconds. Re-enables the test on win-arm and Linux. MacOS still fails with the following network errors, that lead to a timeout: ``` services/network/p2p/socket_manager.cc:137 Failed to resolve address for 9218b16a-a784-40f0-9384-0dec7712202d.local., errorcode: -105 third_party/webrtc/p2p/base/p2p_transport_channel.cc:1274 Failed to resolve ICE candidate hostname 9218b16a-a784-40f0-9384-0dec7712202d.local with error -1 ``` Bug: 377072733 414687402 Change-Id: I2e367bdcb9185437d8db4840b5b3ccc70143de7c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6913845 Reviewed-by: Henrik Boström <hbos@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Steve Becker <stevebe@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1513170} Co-authored-by: Steve Becker <stevebe@microsoft.com>
1 parent bc09e43 commit 18232b4

5 files changed

+116
-123
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// META: title=RTCDataChannel.prototype.send with large ArrayBuffer
2+
// META: script=RTCPeerConnection-helper.js
3+
// META: script=RTCDataChannel-send-close-helper.js
4+
// META: timeout=long
5+
6+
'use strict';
7+
8+
const largeString = ' '.repeat(largeSendDataLength);
9+
const largeArrayBuffer = new TextEncoder('utf-8').encode(largeString);
10+
rtc_data_channel_send_close_test(/*sendData=*/ largeArrayBuffer);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// META: title=RTCDataChannel.prototype.send with large Blob
2+
// META: script=RTCPeerConnection-helper.js
3+
// META: script=RTCDataChannel-send-close-helper.js
4+
// META: timeout=long
5+
6+
'use strict';
7+
8+
const largeBlob = new Blob([' '.repeat(largeSendDataLength)]);
9+
rtc_data_channel_send_close_test(/*sendData=*/ largeBlob);
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// META: script=RTCPeerConnection-helper.js
2+
3+
const largeSendDataLength = 64 * 1024;
4+
5+
function rtc_data_channel_send_close_test(sendData) {
6+
// Run the test twice: once with a regular data channel and once with a
7+
// negotiated data channel.
8+
for (const options of [{}, {negotiated: true, id: 0}]) {
9+
const mode = `${options.negotiated ? 'Negotiated d' : 'D'}atachannel`;
10+
11+
// Determine the type of the data being sent.
12+
let sendDataType = typeof (sendData);
13+
if (sendDataType === 'object') {
14+
if (ArrayBuffer.isView(sendData)) {
15+
sendDataType = 'arraybuffer';
16+
} else if (sendData instanceof Blob) {
17+
sendDataType = 'blob';
18+
}
19+
}
20+
21+
// Determine the length of the data being sent.
22+
let sendDataLength = 0;
23+
switch (sendDataType) {
24+
case 'string':
25+
sendDataLength = sendData.length;
26+
break;
27+
case 'arraybuffer':
28+
sendDataLength = sendData.byteLength;
29+
break;
30+
case 'blob':
31+
sendDataLength = sendData.size;
32+
break;
33+
}
34+
35+
promise_test(
36+
async t => {
37+
assert_greater_than(
38+
sendDataLength, 0,
39+
'`sendData` must be a string, Blob or ArrayBuffer view.');
40+
41+
let [channel1, channel2] = await createDataChannelPair(t, options);
42+
let receivedSize = 0, sentSize = 0;
43+
44+
channel2.binaryType = 'arraybuffer';
45+
channel2.onmessage = e => {
46+
if (typeof e.data === 'string')
47+
receivedSize += e.data.length;
48+
else
49+
receivedSize += e.data.byteLength;
50+
};
51+
52+
channel2.onerror = event => {
53+
assert_unreached(
54+
`channel2 must not dispatch error events: ${event.error}.`);
55+
};
56+
57+
let closePromiseResolve;
58+
let closePromise = new Promise((resolve, reject) => {
59+
closePromiseResolve = resolve;
60+
});
61+
channel2.onclose = e => {
62+
closePromiseResolve();
63+
};
64+
65+
try {
66+
while (sentSize < 20 * 1024 * 1024) {
67+
channel1.send(sendData);
68+
sentSize += sendDataLength;
69+
}
70+
} catch (error) {
71+
assert_true(error instanceof DOMException);
72+
assert_equals(error.name, 'OperationError');
73+
}
74+
channel1.onerror = event => {
75+
assert_unreached(
76+
`channel1 must not dispatch error events: ${event.error}.`);
77+
};
78+
channel1.close();
79+
80+
await closePromise;
81+
assert_equals(
82+
receivedSize, sentSize,
83+
'All the pending sent messages are received after calling close()');
84+
},
85+
`${mode} should be able to send and receive all ${
86+
sendDataType} messages on close`);
87+
}
88+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// META: title=RTCDataChannel.prototype.send with large string
2+
// META: script=RTCPeerConnection-helper.js
3+
// META: script=RTCDataChannel-send-close-helper.js
4+
// META: timeout=long
5+
6+
'use strict';
7+
8+
const largeString = ' '.repeat(largeSendDataLength);
9+
rtc_data_channel_send_close_test(/*sendData=*/ largeString);

webrtc/RTCDataChannel-send-close.html

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)