summaryrefslogtreecommitdiffstats
path: root/image/test/mochitest/test_drawDiscardedImage.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--image/test/mochitest/test_drawDiscardedImage.html85
1 files changed, 85 insertions, 0 deletions
diff --git a/image/test/mochitest/test_drawDiscardedImage.html b/image/test/mochitest/test_drawDiscardedImage.html
new file mode 100644
index 0000000000..f1a2dde89c
--- /dev/null
+++ b/image/test/mochitest/test_drawDiscardedImage.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=731419
+-->
+<head>
+ <title>Test for Bug 731419 - Draw an ostensibly discarded image to a canvas</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+
+<body>
+
+<!--
+ Load an image in an iframe, then draw that image to a canvas. Then set the
+ iframe to display:none (after bug 731419, this causes the image's decoded
+ data to be discarded) and draw the image to a canvas again. We should draw
+ the same image data both times.
+-->
+
+<script>
+
+SimpleTest.waitForExplicitFinish();
+
+var data1;
+
+function drawImage()
+{
+ var canvas = document.getElementById('canvas');
+ var ctx = canvas.getContext('2d');
+ var iframeDoc = document.getElementById('iframe').contentDocument;
+
+ ctx.clearRect(0, 0, canvas.height, canvas.width);
+ ctx.drawImage(iframeDoc.getElementById('image'), 0, 0);
+ return canvas.toDataURL();
+}
+
+function iframeLoad()
+{
+ data1 = drawImage();
+ document.getElementById('iframe').style.display = 'none';
+
+ // Spin the event loop a few times to give the image in the display:none
+ // iframe a chance to be discarded.
+ SimpleTest.executeSoon(function() {
+ SimpleTest.executeSoon(function() {
+ SimpleTest.executeSoon(function() {
+ step2();
+ });
+ });
+ });
+}
+
+function step2()
+{
+ is(drawImage(), data1, "Same image before and after iframe display:none");
+ SimpleTest.finish();
+}
+
+</script>
+
+<canvas id='canvas'></canvas>
+
+<iframe id='iframe' onload='iframeLoad()' srcdoc='<img id="image"
+src="data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