File: MediaStreamTrack-contentHint.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (111 lines) | stat: -rw-r--r-- 3,829 bytes parent folder | download | duplicates (29)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE HTML>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<canvas id="canvas">
</canvas>
<script>

function createAudioTrack() {
  ac = new AudioContext();
  var osc = ac.createOscillator();
  var dest = ac.createMediaStreamDestination();
  osc.connect(dest);
  audio_track = dest.stream.getAudioTracks()[0];

  assert_equals(audio_track.kind, "audio");
  return audio_track;
}

function createVideoTrack() {
  canvas = document.getElementById("canvas");
  video_track = canvas.captureStream().getVideoTracks()[0];

  assert_equals(video_track.kind, "video");
  return video_track;
}

test(t => {
  audio_track = createAudioTrack();
  assert_equals("", audio_track.contentHint);

  video_track = createVideoTrack();
  assert_equals("", video_track.contentHint);
}, "Tracks have empty default content hint");

test(t => {
  audio_track = createAudioTrack();
  audio_track.contentHint = "speech";
  assert_equals(audio_track.contentHint, "speech");
  audio_track.contentHint = "music";
  assert_equals(audio_track.contentHint, "music");
  audio_track.contentHint = "";
  assert_equals(audio_track.contentHint, "");
}, "Accepts valid audio contentHints");

test(t => {
  audio_track = createAudioTrack();
  audio_track.contentHint = "speech";
  assert_equals(audio_track.contentHint, "speech");
  audio_track.contentHint = "motion";
  assert_equals(audio_track.contentHint, "speech",
                "Audio tracks should ignore video-only contentHints.");
  audio_track.contentHint = "bogus";
  assert_equals(audio_track.contentHint, "speech",
                "Audio tracks should ignore garbage contentHints");
}, "Audio tracks ignore invalid/video contentHints");

test(t => {
  video_track = createVideoTrack();
  video_track.contentHint = "motion";
  assert_equals(video_track.contentHint, "motion");
  video_track.contentHint = "detail";
  assert_equals(video_track.contentHint, "detail");
  video_track.contentHint = "text";
  assert_equals(video_track.contentHint, "text");
  video_track.contentHint = "";
  assert_equals(video_track.contentHint, "");
}, "Accepts valid video contentHints");

test(t => {
  video_track = createVideoTrack();
  video_track.contentHint = "motion";
  assert_equals(video_track.contentHint, "motion");
  video_track.contentHint = "speech";
  assert_equals(video_track.contentHint, "motion",
                "Video tracks should ignore audio-only contentHints.");
  video_track.contentHint = "bogus";
  assert_equals(video_track.contentHint, "motion",
                "Video tracks should ignore garbage contentHints");
}, "Video tracks ignore invalid/audio contentHints");

test(t => {
  video_track = createVideoTrack();
  video_track.contentHint = "motion";
  assert_equals(video_track.contentHint, "motion");

  // Cloning a track should preserve contentHint.
  video_track_clone = video_track.clone();
  assert_equals(video_track_clone.contentHint, "motion");

  // Changing a cloned track's contentHint should not change the original.
  video_track_clone.contentHint = "detail";
  assert_equals(video_track_clone.contentHint, "detail");
  assert_equals(video_track.contentHint, "motion");
}, "Cloned video tracks have separate contentHints");

test(t => {
  audio_track = createAudioTrack();
  audio_track.contentHint = "speech";
  assert_equals(audio_track.contentHint, "speech");

  // Cloning a track should preserve contentHint.
  audio_track_clone = audio_track.clone();
  assert_equals(audio_track_clone.contentHint, "speech");

  // Changing a cloned track's contentHint should not change the original.
  audio_track_clone.contentHint = "music";
  assert_equals(audio_track_clone.contentHint, "music");
  assert_equals(audio_track.contentHint, "speech");
}, "Cloned audio tracks have separate contentHints");

</script>