summaryrefslogtreecommitdiffstats
path: root/image/test/mochitest/test_bug435296.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /image/test/mochitest/test_bug435296.html
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'image/test/mochitest/test_bug435296.html')
-rw-r--r--image/test/mochitest/test_bug435296.html85
1 files changed, 85 insertions, 0 deletions
diff --git a/image/test/mochitest/test_bug435296.html b/image/test/mochitest/test_bug435296.html
new file mode 100644
index 0000000000..1610410b16
--- /dev/null
+++ b/image/test/mochitest/test_bug435296.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=435296
+-->
+<head>
+ <title>Test for Bug 435296</title>
+ <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="imgutils.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=435296">Mozilla Bug 435296</a>
+<img id="testimage" style="display: none;">
+<pre id="test">
+<script type="application/javascript">
+
+// Boilerplate
+SimpleTest.waitForExplicitFinish();
+
+// Assert that discarding isn't enabled, which might make this test go orange.
+ok(!getImagePref(DISCARD_ENABLED_PREF), "discarding should NOT be enabled here");
+
+// We want to make sure d-o-d is enabled, since that's what we're testing
+var oldDODPref = getImagePref(DECODEONDRAW_ENABLED_PREF);
+setImagePref(DECODEONDRAW_ENABLED_PREF, true);
+
+// We're relying on very particular behavior for certain images - clear the
+// image cache.
+clearImageCache();
+
+// In order to work around the effects introduced in bug 512435, we only load
+// the image after window onload fires
+function windowLoadHandler()
+{
+ // Set the source and an onload handler
+ var image = document.getElementById("testimage");
+ image.src = "schrep.png";
+ image.onload = imageLoadHandler;
+}
+
+function imageLoadHandler()
+{
+ // The image is hidden, so it should not be decoded
+ ok(!isFrameDecoded("testimage"), "image should not be decoded");
+
+ // Make the image visible
+ var image = document.getElementById("testimage");
+ image.style.display = "inline";
+
+ // Wait for the image to decode
+ setTimeout(function() {
+ tryToFinish();
+ }, 500);
+}
+
+function tryToFinish()
+{
+ // If it hasn't happened yet, wait longer. If it never happens, this test
+ // will timeout after 300 seconds...
+ if (!isFrameDecoded("testimage")) {
+ setTimeout(function() {
+ tryToFinish();
+ }, 500);
+ return;
+ }
+
+ // By definition, the image is decoded here. Give ourselves a pat on the back.
+ ok(isFrameDecoded("testimage"), "image should be decoded");
+
+ // Restore the decode-on-draw pref
+ setImagePref(DECODEONDRAW_ENABLED_PREF, oldDODPref);
+
+ // All done
+ SimpleTest.finish();
+}
+
+// Set our onload handler, making sure we have focus
+window.onload = SimpleTest.waitForFocus(windowLoadHandler);
+
+</script>
+</pre>
+</body>
+</html>