Bug 1126091 - Rewrite GIF webcam reftest as mochitest due to intermittents. r=tnikkel, a=test-only
authorAndrew Osmond <aosmond@mozilla.com>
Tue, 13 Dec 2016 15:41:41 -0500
changeset 353482 fbf2489167ea57ee84f5f0d0881b4e839a354191
parent 353481 9067cd1a72829869124cd4593a8cf3035a1489dd
child 353483 142e00af396681004d8c9ed9e203617b6847ee7c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, test-only
bugs1126091
milestone52.0a2
Bug 1126091 - Rewrite GIF webcam reftest as mochitest due to intermittents. r=tnikkel, a=test-only
image/test/mochitest/blue.gif
image/test/mochitest/mochitest.ini
image/test/mochitest/test_webcam.html
image/test/mochitest/webcam-simulacrum.sjs
image/test/reftest/gif/reftest.list
image/test/reftest/gif/webcam-simulacrum.mgif
image/test/reftest/gif/webcam-simulacrum.mgif^headers^
image/test/reftest/gif/webcam.html
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..339f3702fb6deada1306e6cee76e0f74c0eb0947
GIT binary patch
literal 45
sc${<hbhEHbWMp7u_`txxAn_kaDE?$&00A8k0g_>0Vsc?*u;%3g0IDDbnE(I)
--- a/image/test/mochitest/mochitest.ini
+++ b/image/test/mochitest/mochitest.ini
@@ -6,16 +6,17 @@ support-files =
   animated-gif.gif
   animated-gif2.gif
   animated-gif_trailing-garbage.gif
   animated-gif-finalframe.gif
   animation.svg
   animationPolling.js
   bad.jpg
   big.png
+  blue.gif
   blue.png
   bug399925.gif
   bug468160.sjs
   bug478398_ONLY.png
   bug490949-iframe.html
   bug490949.sjs
   bug496292-1.sjs
   bug496292-2.sjs
@@ -75,16 +76,17 @@ support-files =
   rillybad.jpg
   schrep.png
   shaver.png
   short_header.gif
   source.png
   transparent.gif
   transparent.png
   over.png
+  webcam-simulacrum.sjs
   6M-pixels.png
   12M-pixels-1.png
   12M-pixels-2.png
 
 [test_animation.html]
 skip-if = os == 'android'
 [test_animation_operators.html]
 [test_animation2.html]
@@ -146,10 +148,11 @@ skip-if = os == 'android'
 skip-if = os == 'android'
 [test_svg_filter_animation.html]
 skip-if = os == 'android'
 [test_synchronized_animation.html]
 #skip-if = os == 'android'
 disabled = bug 1295501
 [test_undisplayed_iframe.html]
 skip-if = os == 'android'
+[test_webcam.html]
 [test_xultree_animation.xhtml]
 skip-if = os == 'android'
new file mode 100644
--- /dev/null
+++ b/image/test/mochitest/test_webcam.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=641748
+
+webcam-simulacrum.mgif is a hand-edited file containing red.gif and blue.gif,
+concatenated together with the relevant headers for
+multipart/x-mixed-replace. Specifically, with the headers in
+webcam-simulacrum.mjpg^headers^, the web browser will get the following:
+
+HTTP 200 OK
+Content-Type: multipart/x-mixed-replace;boundary=BOUNDARYOMG
+
+\-\-BOUNDARYOMG\r\n
+Content-Type: image/gif\r\n
+\r\n
+<contents of red.gif> (no newline)
+\-\-BOUNDARYOMG\r\n
+Content-Type: image/gif\r\n
+\r\n
+<contents of blue.gif> (no newline)
+\-\-BOUNDARYOMG\-\-\r\n
+
+(The boundary is arbitrary, and just has to be defined as something that
+won't be in the text of the contents themselves. \-\-$(boundary)\r\n means
+"Here is the beginning of a boundary," and \-\-$(boundary)\-\- means "All done
+sending you parts.")
+-->
+<head>
+  <title>Test for Bug 641748 - WebCam Simulacrum</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+  <script type="application/javascript" src="imgutils.js"></script>
+  <script type="application/javascript" src="animationPolling.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=641748">
+Mozilla Bug 641748: GIF decoder doesn't support multipart/x-mixed-replace
+</a>
+<p id="display"></p>
+
+<div id="content">
+  <div id="referenceDiv" style="height: 100px; width: 100px;
+                                display: none; background: #0018ff;"></div>
+  <div id="animatedImage">
+    <img id="animatedGif" src="webcam-simulacrum.sjs" style="display: none; height: 100px; width: 100px;">
+      <div id="text-descr"></div>
+  </div>
+  <div id="debug" style="display:none">
+  </div>
+</div>
+<pre id="test">
+<script type="text/javascript;version=1.8">
+const FAILURE_TIMEOUT = 60000; // Fail early after 60 seconds
+
+function main()
+{
+  var animTest = new AnimationTest(20, FAILURE_TIMEOUT, 'referenceDiv',
+                                   'animatedGif', 'debug');
+  animTest.beginTest();
+}
+
+window.onload = main;
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/image/test/mochitest/webcam-simulacrum.sjs
@@ -0,0 +1,51 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var counter = 2;
+var frames = ['red.gif', 'blue.gif'];
+var timer = Components.classes["@mozilla.org/timer;1"];
+var partTimer = timer.createInstance(Components.interfaces.nsITimer);
+
+function getFileAsInputStream(aFilename) {
+  var file = Components.classes["@mozilla.org/file/directory_service;1"]
+             .getService(Components.interfaces.nsIProperties)
+             .get("CurWorkD", Components.interfaces.nsIFile);
+
+  file.append("tests");
+  file.append("image");
+  file.append("test");
+  file.append("mochitest");
+  file.append(aFilename);
+
+  var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
+                   .createInstance(Components.interfaces.nsIFileInputStream);
+  fileStream.init(file, 1, 0, false);
+  return fileStream;
+}
+
+function handleRequest(request, response)
+{
+  response.setHeader("Content-Type",
+                     "multipart/x-mixed-replace;boundary=BOUNDARYOMG", false);
+  response.setHeader("Cache-Control", "no-cache", false);
+  response.setStatusLine(request.httpVersion, 200, "OK");
+  response.processAsync();
+  response.write("--BOUNDARYOMG\r\n");
+  while (frames.length > 0) {
+    sendNextPart(response);
+  }
+  response.write("--BOUNDARYOMG--\r\n");
+  response.finish();
+}
+
+function sendNextPart(response) {
+  var nextPartHead = "Content-Type: image/gif\r\n\r\n";
+  var inputStream = getFileAsInputStream(frames.shift());
+  response.bodyOutputStream.write(nextPartHead, nextPartHead.length);
+  response.bodyOutputStream.writeFrom(inputStream, inputStream.available());
+  inputStream.close();
+  // Toss in the boundary, so the browser can know this part is complete
+  response.write("--BOUNDARYOMG\r\n");
+}
+
--- a/image/test/reftest/gif/reftest.list
+++ b/image/test/reftest/gif/reftest.list
@@ -22,32 +22,8 @@ skip == test_bug641198.html animation2a-
 # Bug 1062886: a gif with a single color and an offset
 == one-color-offset.gif one-color-offset-ref.gif
 
 # Bug 1068230
 == tile-transform.html tile-transform-ref.html
 
 # Bug 1234077
 == truncated-framerect.html truncated-framerect-ref.html
-
-# webcam-simulacrum.mgif is a hand-edited file containing red.gif and blue.gif,
-# concatenated together with the relevant headers for
-# multipart/x-mixed-replace. Specifically, with the headers in
-# webcam-simulacrum.mjpg^headers^, the web browser will get the following:
-#
-# HTTP 200 OK
-# Content-Type: multipart/x-mixed-replace;boundary=BOUNDARYOMG
-#
-# --BOUNDARYOMG\r\n
-# Content-Type: image/gif\r\n
-# \r\n
-# <contents of red.gif> (no newline)
-# --BOUNDARYOMG\r\n
-# Content-Type: image/gif\r\n
-# \r\n
-# <contents of blue.gif> (no newline)
-# --BOUNDARYOMG--\r\n
-#
-# (The boundary is arbitrary, and just has to be defined as something that
-# won't be in the text of the contents themselves. --$(boundary)\r\n means
-# "Here is the beginning of a boundary," and --$(boundary)-- means "All done
-# sending you parts.")
-HTTP == webcam.html blue.gif
deleted file mode 100644
index 8302c3955cf66769a988a6b239e76e25cc515122..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/image/test/reftest/gif/webcam-simulacrum.mgif^headers^
+++ /dev/null
@@ -1,3 +0,0 @@
-HTTP 200 OK
-Content-Type: multipart/x-mixed-replace;boundary=BOUNDARYOMG
-Cache-Control: no-cache
deleted file mode 100644
--- a/image/test/reftest/gif/webcam.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<head><link rel="stylesheet" href="ImageDocument.css"></head>
-<body>
-<img src="webcam-simulacrum.mgif">
-</body></html>