blob: 268c1706a48ed5ca605d2e5f1e9c40980911d372 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing bufferedAmountLowThreashold default RTCDataChannel attribute and event</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script src ="../routines.js"></script>
<script>
window.addEventListener("unhandledrejection", event => {
event.preventDefault();
});
var localChannel;
var remoteChannel;
function closeDataChannels() {
localChannel.close();
remoteChannel.close();
closeConnections();
}
var longString = "abcdefgh";
for (var cptr = 0; cptr < 10; ++cptr)
longString += longString;
function sendMessages(channel)
{
while(channel.bufferedAmount < 1000)
channel.send(longString);
}
function receiveMessages(event) {
if (++counter === 1)
return;
}
promise_test((test) => {
counter = 0;
var gotEvent = false;
return new Promise((resolve, reject) => {
createConnections((localConnection) => {
localChannel = localConnection.createDataChannel('sendDataChannel');
localChannel.onopen = () => { sendMessages(localChannel); };
localChannel.onbufferedamountlow = () => {
resolve();
}
assert_equals(localChannel.bufferedAmountLowThreshold, 0, "default bufferedAmountLowThreshold value");
}, (remoteConnection) => {
remoteConnection.ondatachannel = (event) => {
remoteChannel = event.channel;
remoteChannel.onmessage = receiveMessages;
};
});
setTimeout(() => reject('timed out'), 5000);
}).then (() => {
closeDataChannels();
});
}, "Default buffer threshold");
</script>
</body>
</html>