File: invalid-third-block.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (59 lines) | stat: -rw-r--r-- 2,423 bytes parent folder | download | duplicates (4)
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Unknown Track Number in Third Block</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
</head>
<body>
</body>
<script>
// Test that an unknown track number in the third webm block triggers the
// append error algorithm.
// https://w3c.github.io/media-source/#byte-stream-formats
// The user agent MUST run the append error algorithm when any combination of
// an initialization segment and any contiguous sequence of media segments
// satisfies the following conditions:
// 1. The number and type (audio, video, text, etc.) of all tracks in the
//    media segments are not identified.
promise_test(async t => {
  const audio = document.createElement('audio');
  audio.controls = true;
  audio.watcher = new EventWatcher(t, audio, ['error']);
  document.body.appendChild(audio);

  const source = new MediaSource();
  source.watcher = new EventWatcher(t, source, ['sourceopen']);
  audio.src = URL.createObjectURL(source);
  await source.watcher.wait_for('sourceopen');

  const resource = await MediaSourceUtil.fetchResourceOfManifest(
    t, 'webm/test-a-128k-44100Hz-1ch-manifest.json');
  assert_implements_optional(MediaSource.isTypeSupported(resource.type),
                             `${resource.type} supported`);

  const buffer = source.addSourceBuffer(resource.type);
  buffer.watcher = new EventWatcher(t, buffer, ['error', 'updateend']);
  // Intentionally append data ending at the end of a cluster having an
  // invalid track number in a block that is after the second block in the
  // cluster, because Gecko had a bug that failed to detect some demux errors
  // in this situation.
  resource.data = resource.data.subarray(0, resource.cluster_start[1]);
  // Choose a track number of zero, which is not in the init segment.
  const track_number = 0;
  // Set the high bit of an octet, for a single-octet EBML VINT.
  const track_number_vint = 1 << 7 | track_number;
  // Skip two bytes for the EBML element ID and data size, and overwrite the
  // track number.
  resource.data[Number(resource.block_start[2]) + 2] = track_number_vint;

  buffer.appendBuffer(resource.data);
  await Promise.all([
    buffer.watcher.wait_for(['error', 'updateend']),
    audio.watcher.wait_for('error'),
  ]);
}, 'invalid-third-block');
</script>
</html>