Bug 1577084 - A mochitest to make sure images outside of display port is not decoded. r=tnikkel
authorHiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Fri, 13 Dec 2019 12:36:52 +0000
changeset 506890 c400f7480696ce9fce0234f857a94965536c0567
parent 506889 adec5f2eb156c86b243d04d29a6023ae6479130b
child 506891 9b4c307ed8a46258a4fb6cc2869a84241f9a75dc
push id36913
push useropoprus@mozilla.com
push dateFri, 13 Dec 2019 16:53:24 +0000
treeherdermozilla-central@1ed684598bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1577084
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577084 - A mochitest to make sure images outside of display port is not decoded. r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D57090
image/test/mochitest/child.html
image/test/mochitest/mochitest.ini
image/test/mochitest/test_animated_gif.html
new file mode 100644
--- /dev/null
+++ b/image/test/mochitest/child.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<script src="imgutils.js"></script>
+<img id="img" src="animated1.gif">
+<script>
+  let observer = new ImageDecoderObserverStub();
+  observer.decodeComplete = () => {
+    parent.postMessage("decodeComplete", "*");
+  };
+  observer.loadComplete = () => {
+    parent.postMessage("loadComplete", "*");
+  };
+  observer = SpecialPowers.wrapCallbackObject(observer);
+  const gObserver = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
+                                 .getService(SpecialPowers.Ci.imgITools)
+                                 .createScriptedObserver(observer);
+  const img = document.getElementById("img");
+  SpecialPowers.wrap(img).addObserver(gObserver);
+  window.addEventListener("unload", () => {
+    SpecialPowers.wrap(img).removeObserver(gObserver);
+  });
+</script>
--- a/image/test/mochitest/mochitest.ini
+++ b/image/test/mochitest/mochitest.ini
@@ -90,16 +90,18 @@ support-files =
   transparent.gif
   transparent.png
   over.png
   webcam-simulacrum.sjs
   6M-pixels.png
   12M-pixels-1.png
   12M-pixels-2.png
 
+[test_animated_gif.html]
+support-files = child.html
 [test_animation.html]
 [test_animation_operators.html]
 [test_animation2.html]
 [test_animSVGImage.html]
 skip-if = os == 'android' || os == 'win' || (os == 'mac' && os_version == '10.14') # Bug 1370784, macosx due to bug 1549058
 [test_animSVGImage2.html]
 skip-if = (webrender && os == 'win') || (webrender && os == 'linux') #Bug 1354561
 [test_background_image_anim.html]
new file mode 100644
--- /dev/null
+++ b/image/test/mochitest/test_animated_gif.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Images outside of display port are not decoded</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="imgutils.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<div id="scroller" style="height: 300px; overflow: scroll;">
+  <div style="width: 100%; height: 5000px;"></div>
+  <iframe src="http://example.org/tests/image/test/mochitest/child.html"></iframe>
+  <div style="width: 100%; height: 5000px;"></div>
+</div>
+<pre id="test"></pre>
+<script>
+  SimpleTest.waitForExplicitFinish();
+
+  let loadCompleteCount = 0;
+  window.addEventListener("message", event => {
+    isnot(event.data, "decodeComplete",
+          "The image outside of the display port should not be decoded");
+    if (event.data == "loadComplete") {
+      loadCompleteCount++
+    }
+  });
+
+  const start = document.timeline.currentTime;
+  // Waits a second;
+  SimpleTest.waitForCondition(() => {
+    return 1000 < (document.timeline.currentTime - start);
+  }, () => {
+    is(loadCompleteCount, 1,
+       "`loadComplete` should be received once");
+    SimpleTest.finish();
+  });
+</script>
+</body>
+</html>