Bug 1294358 - P4: Shrink video size. r?jya draft
authorDan Glastonbury <dglastonbury@mozilla.com>
Mon, 22 Aug 2016 15:30:05 +1000
changeset 403812 d207dc4ae636672f8884be8234aea1b51fbc4f5c
parent 403811 45702b22a66cdafedbc1c57e38d39671c72e8ad1
child 529006 2f811c7e1947821555876ac2b247066a64ff3eb4
push id27017
push userbmo:dglastonbury@mozilla.com
push dateMon, 22 Aug 2016 08:11:44 +0000
reviewersjya
bugs1294358
milestone51.0a1
Bug 1294358 - P4: Shrink video size. r?jya Make the test videos smaller so they are visible in the mochitest iframe.
dom/media/test/background_video.js
dom/media/test/test_background_video_no_suspend_disabled.html
dom/media/test/test_background_video_no_suspend_short_vid.html
dom/media/test/test_background_video_suspend.html
dom/media/test/test_background_video_suspend_ends.html
--- a/dom/media/test/background_video.js
+++ b/dom/media/test/background_video.js
@@ -13,20 +13,26 @@ function startTest(test) {
     manager.runTests(test.tests, test.runTest);
   });
 }
 
 /**
  * @param {string} url video src.
  * @returns {HTMLMediaElement} The created video element.
  */
-function appendVideoToDoc(url, token) {
+function appendVideoToDoc(url, token, width, height) {
+  // Default size of (160, 120) is used by other media tests.
+  if (width === undefined) { width = 160; }
+  if (height === undefined) { height = 3*width/4; }
+
   let v = document.createElement('video');
   v.token = token;
   document.body.appendChild(v);
+  v.width = width;
+  v.height = height;
   v.src = url;
   return v;
 }
 
 /**
  * @param {HTMLMediaElement} video Video element under test.
  * @returns {Promise} Promise that is resolved when video 'playing' event fires and rejected on error.
  */
@@ -101,9 +107,9 @@ function waitTil(video, time) {
   return new Promise(resolve => {
     video.addEventListener('timeupdate', function timeUpdateEvent() {
       if (video.currentTime > time) {
         video.removeEventListener(name, timeUpdateEvent);
         resolve();
       }
     });
   });
-}
\ No newline at end of file
+}
--- a/dom/media/test/test_background_video_no_suspend_disabled.html
+++ b/dom/media/test/test_background_video_no_suspend_disabled.html
@@ -1,18 +1,15 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test Background Video Doesn't Suspend When Feature Disabled</title>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <script src="manifest.js"></script>
 <script src="background_video.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
-<p id="display">
-<div id="content" style="display:none"></div>
-<pre id="test">
 <script>
 "use strict";
 
 var manager = new MediaTestManager;
 
 startTest({
   desc: "Test Background Video Doesn't Suspend When Feature Disabled.",
   prefs: [
@@ -31,10 +28,9 @@ startTest({
       .then(() => {
         ok(true, 'Video ended before decode was suspended');
         manager.finished(token); })
       .catch((e) => {
         ok(false, 'Test Failed: ' + e.toString());
         manager.finished(token); });
   }
 });
-</script>
-</pre>
\ No newline at end of file
+</script>
\ No newline at end of file
--- a/dom/media/test/test_background_video_no_suspend_short_vid.html
+++ b/dom/media/test/test_background_video_no_suspend_short_vid.html
@@ -1,18 +1,15 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test Background Video Doesn't Suspend When Timeout Is Longer Than Video</title>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <script src="manifest.js"></script>
 <script src="background_video.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
-<p id="display">
-<div id="content" style="display:none"></div>
-<pre id="test">
 <script>
 "use strict";
 
 var manager = new MediaTestManager;
 
 startTest({
   desc: "Test Background Video Doesn't Suspend When Timeout Is Longer Than Video.",
   prefs: [
@@ -33,10 +30,9 @@ startTest({
       .then(() => {
         ok(true, 'Video ended before decode was suspended');
         manager.finished(token); })
       .catch((e) => {
         ok(false, 'Test Failed: ' + e.toString());
         manager.finished(token); });
   }
 });
-</script>
-</pre>
\ No newline at end of file
+</script>
\ No newline at end of file
--- a/dom/media/test/test_background_video_suspend.html
+++ b/dom/media/test/test_background_video_suspend.html
@@ -1,18 +1,15 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test Background Video Suspends</title>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <script src="manifest.js"></script>
 <script src="background_video.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
-<p id="display">
-<div id="content" style="display: none"></div>
-<pre id="test">
 <script type="text/javascript">
 "use strict";
 
 var manager = new MediaTestManager;
 
 function testDelay(start, min, max) {
   let end = performance.now();
   let delay = end - start;
@@ -39,10 +36,9 @@ startTest({
       .then(() => testVideoSuspendsWhenHidden(v))
       .then(() => testDelay(start, 1000, 10000))
       .then(() => waitTil(v, v.duration / 2))
       .then(() => testVideoResumesWhenShown(v))
       .then(() => waitUntilEnded(v))
       .then(() => { manager.finished(token); });
   }
 });
-</script>
-</pre>
\ No newline at end of file
+</script>
\ No newline at end of file
--- a/dom/media/test/test_background_video_suspend_ends.html
+++ b/dom/media/test/test_background_video_suspend_ends.html
@@ -1,18 +1,15 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test Background Suspended Video Fires 'ended' Event</title>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <script src="manifest.js"></script>
 <script src="background_video.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
-<p id="display">
-<div id="content" style="display: none"></div>
-<pre id="test">
 <script type="text/javascript">
 "use strict";
 
 var manager = new MediaTestManager;
 
 startTest({
   desc: "Test Background Suspended Video Fires 'ended' Event",
   prefs: [
@@ -35,9 +32,8 @@ startTest({
       .then(() => waitUntilEnded(v))
       .then(() => {
         ok(v.currentTime >= v.duration, 'current time approximates duration.');
         manager.finished(token);
       });
   }
 });
 </script>
-</pre>