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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<!DOCTYPE html>
<html>
<head>
<title>Test the special debug APIs give expected data</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
<script class="testbody" type="text/javascript">
add_task(async function testMozRequestDebugInfo() {
let video = document.createElement("video");
video.src = "gizmo.mp4";
document.body.appendChild(video);
await video.play();
let debugData = await SpecialPowers.wrap(video).mozRequestDebugInfo();
// Verify various members are present and as expected.
ok(debugData, "Should get some debug data");
ok(debugData.decoder.hasAudio, "Should have audio");
ok(debugData.decoder.hasVideo, "Should have video");
is(
debugData.decoder.reader.videoWidth,
560,
"Video should have expected width"
);
is(
debugData.decoder.reader.videoHeight,
320,
"Video should have expected height"
);
ok(
debugData.decoder.stateMachine.mediaTime >= 0,
"Media time should be positive"
);
removeNodeAndSource(video);
});
add_task(async function testMozDebugReaderData() {
let video = document.createElement("video");
let mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);
await once(mediaSource, "sourceopen");
const sourceBuffer = mediaSource.addSourceBuffer("video/webm");
let fetchResponse = await fetch("bipbop_short_vp8.webm");
sourceBuffer.appendBuffer(await fetchResponse.arrayBuffer());
await once(sourceBuffer, "updateend");
mediaSource.endOfStream();
await once(mediaSource, "sourceended");
document.body.appendChild(video);
await video.play();
let debugData = await SpecialPowers.wrap(mediaSource).mozDebugReaderData();
// Verify various members are present and as expected.
ok(debugData, "Should get some debug data");
is(debugData.reader.videoWidth, 400, "Video should have expected width");
is(debugData.reader.videoHeight, 300, "Video should have expected height");
ok(
debugData.demuxer.audioTrack.numSamples > 0,
"Audio track should have demuxed some samples"
);
ok(
debugData.demuxer.audioTrack.ranges.length,
"Audio track should have some buffered range"
);
ok(
debugData.demuxer.videoTrack.numSamples > 0,
"Video track should have demuxed some samples"
);
ok(
debugData.demuxer.videoTrack.ranges.length,
"Video track should have some buffered range"
);
removeNodeAndSource(video);
});
</script>
</head>
</html>
|