Bug 879717 - Part 3: Test video dimensions set on loadedmetadata event. r=roc, a=lmandel
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 19 Dec 2014 01:25:00 +0100
changeset 249326 c98d9fcee9348ee57aba72edb34fd81b1969c8ec
parent 249325 05abbe4ec215b53b98d6aadbd8821c303cce9b74
child 249327 cbfab5a8210d800867dd49be428503f37cae426a
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lmandel
bugs879717
milestone37.0a2
Bug 879717 - Part 3: Test video dimensions set on loadedmetadata event. r=roc, a=lmandel
dom/media/test/manifest.js
dom/media/test/mochitest.ini
dom/media/test/test_video_dimensions.html
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -9,17 +9,17 @@ var gSmallTests = [
   { name:"small-shot.m4a", type:"audio/mp4", duration:0.29 },
   { name:"small-shot.mp3", type:"audio/mpeg", duration:0.27 },
   { name:"small-shot-mp3.mp4", type:"audio/mp4; codecs=mp3", duration:0.34 },
   { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
   { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
   { name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
   { name:"vp9.webm", type:"video/webm", width:320, height:240, duration:4 },
   { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
-  { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
+  { name:"gizmo.mp4", type:"video/mp4", width:560, height:320, duration:5.56 },
   { name:"bogus.duh", type:"bogus/duh" }
 ];
 
 if (SpecialPowers.Services.appinfo.name != "B2G") {
   // We only run mochitests on b2g desktop and b2g emulator. The 3gp codecs
   // aren't present on desktop, and the emulator codecs (which are different
   // from the real device codecs) don't pass all of our tests, so we need
   // to disable them.
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -466,16 +466,17 @@ skip-if = (toolkit == 'android' && proce
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
 [test_readyState.html]
 [test_referer.html]
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
 [test_replay_metadata.html]
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
 [test_reset_events_async.html]
 [test_reset_src.html]
+[test_video_dimensions.html]
 [test_resume.html]
 skip-if = true # bug 1021673
 [test_seek_out_of_range.html]
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
 [test_seek-1.html]
 skip-if = android_version == '10' # bug 1059116
 [test_seek-2.html]
 [test_seek-3.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_video_dimensions.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test that a video element has set video dimensions on loadedmetadata</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var manager = new MediaTestManager;
+
+var startTest = function(test, token) {
+  manager.started(token);
+  var v1 = document.createElement('video');
+  var v2 = document.createElement('video');
+  var vout = document.createElement('video');
+
+  // Avoid a race for hardware resources between v1 and v2 on platforms with
+  // a hardware decoder, like B2G.
+  v1.preload = 'none';
+  v2.preload = 'none';
+
+  var numVideoElementsFinished = 0;
+
+  var onloadedmetadata = function(ev) {
+    var v = ev.target;
+    ok(!v.loadedmetadata, v.testName + " should only fire loadedmetadata once");
+    v.loadedmetadata = true;
+    is(v.videoWidth, test.width, v.testName + " video width should be set on loadedmetadata");
+    is(v.videoHeight, test.height, v.testName + " video height should be set on loadedmetadata");
+
+    numVideoElementsFinished += 1;
+    if (v === v1) {
+      removeNodeAndSource(v1);
+      v2.play();
+      vout.play();
+    }
+
+    if (numVideoElementsFinished === 3) {
+      removeNodeAndSource(v2);
+      removeNodeAndSource(vout);
+      manager.finished(token);
+    }
+  };
+  var setupElement = function(v, id) {
+    v.loadedmetadata = false;
+    v.onloadedmetadata = onloadedmetadata;
+    document.body.appendChild(v);
+  };
+
+  v1.testName = test.name;
+  v2.testName = test.name + " (Captured)";
+  vout.testName = test.name + " (Stream)";
+
+  v1.src = test.name;
+  v2.src = test.name;
+  vout.src = URL.createObjectURL(v2.mozCaptureStreamUntilEnded());
+
+  setupElement(v1, "v1");
+  setupElement(v2, "v2");
+  setupElement(vout, "vout");
+
+  v1.play();
+};
+
+manager.runTests(getPlayableVideos(gSmallTests), startTest);
+</script>
+</pre>
+</body>
+</html>