forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdtmf-gc.html
51 lines (46 loc) · 1.58 KB
/
dtmf-gc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/gc.js"></script>
</head>
<body>
<video id="video" autoplay playsInline></video>
<script src ="routines.js"></script>
<script>
promise_test(async (test) => {
let sender;
const localStream = await navigator.mediaDevices.getUserMedia({audio:true, video:true});
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
sender = firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();
const string = '0123456789ABCD';
let counter = 0;
const promise = new Promise((resolve, reject) => {
sender.dtmf.ontonechange = () => {
if (++counter === string.length)
resolve();
};
setTimeout(() => reject('dtmf timed out with counter ' + counter), 5000);
});
sender.dtmf.insertDTMF(string);
gc();
gc();
gc();
return promise;
}, "Make sure DTMF does not get GCed while it can fire events");
</script>
</body>
</html>