Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Video controls test</title>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" 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>
13 <pre id="test">
14 <script class="testbody" type="text/javascript">
16 const videoWidth = 320;
17 const videoHeight = 240;
19 function getMediaElement(aWindow) {
20 return aWindow.document.getElementsByTagName("video")[0];
21 }
23 var popup = window.open("seek_with_sound.ogg");
24 popup.addEventListener("load", function onLoad() {
25 popup.removeEventListener("load", onLoad);
26 var video = getMediaElement(popup);
27 if (!video.paused)
28 runTestVideo(video);
29 else {
30 video.addEventListener("play", function onPlay() {
31 video.removeEventListener("play", onPlay);
32 runTestVideo(video);
33 });
34 }
35 });
37 function runTestVideo(aVideo) {
38 var condition = function() {
39 var boundingRect = aVideo.getBoundingClientRect();
40 return boundingRect.width == videoWidth &&
41 boundingRect.height == videoHeight;
42 };
43 waitForCondition(condition, function() {
44 var boundingRect = aVideo.getBoundingClientRect();
45 is(boundingRect.width, videoWidth, "Width of the video should match expectation");
46 is(boundingRect.height, videoHeight, "Height of video should match expectation");
47 popup.close();
48 runTestAudioPre();
49 }, "The media element should eventually be resized to match the intrinsic size of the video.");
50 }
52 function runTestAudioPre() {
53 popup = window.open("audio.ogg");
54 popup.addEventListener("load", function onLoad() {
55 popup.removeEventListener("load", onLoad);
56 var audio = getMediaElement(popup);
57 if (!audio.paused)
58 runTestAudio(audio);
59 else {
60 audio.addEventListener("play", function onPlay() {
61 audio.removeEventListener("play", onPlay);
62 runTestAudio(audio);
63 })
64 }
65 })
66 }
68 function runTestAudio(aAudio) {
69 info("User agent (help diagnose bug #943556): " + navigator.userAgent);
70 var isAndroid = navigator.userAgent.contains("Android");
71 var expectedHeight = isAndroid ? 123 : 28;
72 var condition = function () {
73 var boundingRect = aAudio.getBoundingClientRect();
74 return boundingRect.height == expectedHeight;
75 };
76 waitForCondition(condition, function () {
77 var boundingRect = aAudio.getBoundingClientRect();
78 is(boundingRect.height, expectedHeight,
79 "Height of audio element should be " + expectedHeight + ", which is equal to the controls bar.");
80 popup.close();
81 SimpleTest.finish();
82 }, "The media element should eventually be resized to match the height of the audio controls.");
83 }
85 SimpleTest.waitForExplicitFinish();
87 </script>
88 </pre>
89 </body>
90 </html>