| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Testing bufferedAmountLowThreashold 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; |
| |
| function closeDataChannels() { |
| localChannel.close(); |
| closeConnections(); |
| } |
| |
| var longString = "abcdefgh"; |
| for (var cptr = 0; cptr < 10; ++cptr) |
| longString += longString; |
| |
| function sendContinuouslyMessages(channel) |
| { |
| try { |
| while (channel.bufferedAmount < 200000) |
| channel.send(longString); |
| |
| setTimeout(() => sendContinuouslyMessages(channel), 0); |
| } catch(e) { |
| } |
| } |
| |
| promise_test((test) => { |
| return new Promise((resolve, reject) => { |
| createConnections((localConnection) => { |
| localChannel = localConnection.createDataChannel('sendDataChannel'); |
| localChannel.onopen = () => { |
| sendContinuouslyMessages(localChannel); |
| localChannel.onbufferedamountlow = () => { |
| resolve(); |
| } |
| }; |
| localChannel.bufferedAmountLowThreshold = 200000; |
| }, (remoteConnection) => { |
| }); |
| setTimeout(() => reject('timed out'), 5000); |
| }).then (() => { |
| closeDataChannels(); |
| }); |
| }, "Large buffer threshold reached"); |
| </script> |
| </body> |
| </html> |