Source code

Revision control

Other Tools

1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<title>Video controls test</title>
5
<script src="/tests/SimpleTest/SimpleTest.js"></script>
6
<script src="/tests/SimpleTest/EventUtils.js"></script>
7
<script type="text/javascript" src="head.js"></script>
8
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9
</head>
10
<body>
11
<p id="display"></p>
12
13
<pre id="test">
14
<script class="testbody" type="text/javascript">
15
SimpleTest.expectAssertions(0, 1);
16
17
const videoWidth = 320;
18
const videoHeight = 240;
19
20
function getMediaElement(aWindow) {
21
return aWindow.document.getElementsByTagName("video")[0];
22
}
23
24
var popup = window.open("seek_with_sound.ogg");
25
popup.addEventListener("load", function() {
26
var video = getMediaElement(popup);
27
28
is(popup.document.activeElement, video, "Document should load with focus moved to the video element.");
29
30
if (!video.paused) {
31
runTestVideo(video);
32
} else {
33
video.addEventListener("play", function() {
34
runTestVideo(video);
35
}, {once: true});
36
}
37
}, {once: true});
38
39
function runTestVideo(aVideo) {
40
var condition = function() {
41
var boundingRect = aVideo.getBoundingClientRect();
42
return boundingRect.width == videoWidth &&
43
boundingRect.height == videoHeight;
44
};
45
waitForCondition(condition, function() {
46
var boundingRect = aVideo.getBoundingClientRect();
47
is(boundingRect.width, videoWidth, "Width of the video should match expectation");
48
is(boundingRect.height, videoHeight, "Height of video should match expectation");
49
popup.close();
50
runTestAudioPre();
51
}, "The media element should eventually be resized to match the intrinsic size of the video.");
52
}
53
54
function runTestAudioPre() {
55
popup = window.open("audio.ogg");
56
popup.addEventListener("load", function() {
57
var audio = getMediaElement(popup);
58
59
is(popup.document.activeElement, audio, "Document should load with focus moved to the video element.");
60
61
if (!audio.paused) {
62
runTestAudio(audio);
63
} else {
64
audio.addEventListener("play", function() {
65
runTestAudio(audio);
66
}, {once: true});
67
}
68
}, {once: true});
69
}
70
71
function runTestAudio(aAudio) {
72
info("User agent (help diagnose bug #943556): " + navigator.userAgent);
73
var isAndroid = navigator.userAgent.includes("Android");
74
var expectedHeight = isAndroid ? 103 : 40;
75
var condition = function() {
76
var boundingRect = aAudio.getBoundingClientRect();
77
return boundingRect.height == expectedHeight;
78
};
79
waitForCondition(condition, function() {
80
var boundingRect = aAudio.getBoundingClientRect();
81
is(boundingRect.height, expectedHeight,
82
"Height of audio element should be " + expectedHeight + ", which is equal to the controls bar.");
83
popup.close();
84
SimpleTest.finish();
85
}, "The media element should eventually be resized to match the height of the audio controls.");
86
}
87
88
SimpleTest.waitForExplicitFinish();
89
90
</script>
91
</pre>
92
</body>
93
</html>