image/test/mochitest/test_bug497665.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/test/mochitest/test_bug497665.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=497665
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 497665</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497665">Mozilla Bug 497665</a>
    1.17 +<p id="display"></p>
    1.18 +<pre id="test">
    1.19 +<script type="application/javascript">
    1.20 +
    1.21 +var image1first, image2first, image1second, image2second, image1third, image2third;
    1.22 +
    1.23 +SimpleTest.waitForExplicitFinish();
    1.24 +
    1.25 +function checkFirst()
    1.26 +{
    1.27 +  var iframeelem = document.getElementById('test-iframe');
    1.28 +  var canvas = document.getElementById('canvas');
    1.29 +  var ctx = canvas.getContext('2d');
    1.30 +
    1.31 +  var firstimg = iframeelem.contentDocument.getElementById('image1');
    1.32 +  var secondimg = iframeelem.contentDocument.getElementById('image2');
    1.33 +  ctx.drawImage(firstimg, 0, 0);
    1.34 +  image1first = canvas.toDataURL();
    1.35 +  ctx.drawImage(secondimg, 0, 0);
    1.36 +  image2first = canvas.toDataURL();
    1.37 +
    1.38 +  ok(image1first == image2first, "We got different images, but shouldn't have.");
    1.39 +
    1.40 +  iframeelem.onload = checkForceReload;
    1.41 +  iframeelem.contentWindow.location.reload(true);
    1.42 +}
    1.43 +
    1.44 +function checkForceReload()
    1.45 +{
    1.46 +  var iframeelem = document.getElementById('test-iframe');
    1.47 +  var canvas = document.getElementById('canvas');
    1.48 +  var ctx = canvas.getContext('2d');
    1.49 +
    1.50 +  var firstimg = iframeelem.contentDocument.getElementById('image1');
    1.51 +  var secondimg = iframeelem.contentDocument.getElementById('image2');
    1.52 +  ctx.drawImage(firstimg, 0, 0);
    1.53 +  image1second = canvas.toDataURL();
    1.54 +  ctx.drawImage(secondimg, 0, 0);
    1.55 +  image2second = canvas.toDataURL();
    1.56 +
    1.57 +  ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have.");
    1.58 +
    1.59 +  // Sanity check that we actually reloaded.
    1.60 +  ok(image1first != image1second, "We got the same images after a force-reload.");
    1.61 +
    1.62 +  iframeelem.onload = checkReload;
    1.63 +  iframeelem.contentWindow.location.reload(false);
    1.64 +}
    1.65 +
    1.66 +function checkReload()
    1.67 +{
    1.68 +  var iframeelem = document.getElementById('test-iframe');
    1.69 +  var canvas = document.getElementById('canvas');
    1.70 +  var ctx = canvas.getContext('2d');
    1.71 +
    1.72 +  var firstimg = iframeelem.contentDocument.getElementById('image1');
    1.73 +  var secondimg = iframeelem.contentDocument.getElementById('image2');
    1.74 +  ctx.drawImage(firstimg, 0, 0);
    1.75 +  image1third = canvas.toDataURL();
    1.76 +  ctx.drawImage(secondimg, 0, 0);
    1.77 +  image2third = canvas.toDataURL();
    1.78 +
    1.79 +  ok(image1third == image2third, "We got different images after a reload, but shouldn't have.");
    1.80 +
    1.81 +  // Sanity check that we actually reloaded properly.
    1.82 +  ok(image1second != image1third, "We got the same images after a reload.");
    1.83 +  ok(image1first == image1third, "We didn't loop back to the first image.");
    1.84 +
    1.85 +  SimpleTest.finish();
    1.86 +}
    1.87 +
    1.88 +</script>
    1.89 +</pre>
    1.90 +<div id="content"> <!-- style="display: none" -->
    1.91 +<canvas id="canvas" width="100" height="100"> </canvas>
    1.92 +<iframe id="test-iframe" src="bug497665-iframe.html" onload="checkFirst()"></iframe>
    1.93 +</div>
    1.94 +</body>
    1.95 +</html>

mercurial