image/test/mochitest/test_bug497665.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=497665
     5 -->
     6 <head>
     7   <title>Test for Bug 497665</title>
     8   <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497665">Mozilla Bug 497665</a>
    14 <p id="display"></p>
    15 <pre id="test">
    16 <script type="application/javascript">
    18 var image1first, image2first, image1second, image2second, image1third, image2third;
    20 SimpleTest.waitForExplicitFinish();
    22 function checkFirst()
    23 {
    24   var iframeelem = document.getElementById('test-iframe');
    25   var canvas = document.getElementById('canvas');
    26   var ctx = canvas.getContext('2d');
    28   var firstimg = iframeelem.contentDocument.getElementById('image1');
    29   var secondimg = iframeelem.contentDocument.getElementById('image2');
    30   ctx.drawImage(firstimg, 0, 0);
    31   image1first = canvas.toDataURL();
    32   ctx.drawImage(secondimg, 0, 0);
    33   image2first = canvas.toDataURL();
    35   ok(image1first == image2first, "We got different images, but shouldn't have.");
    37   iframeelem.onload = checkForceReload;
    38   iframeelem.contentWindow.location.reload(true);
    39 }
    41 function checkForceReload()
    42 {
    43   var iframeelem = document.getElementById('test-iframe');
    44   var canvas = document.getElementById('canvas');
    45   var ctx = canvas.getContext('2d');
    47   var firstimg = iframeelem.contentDocument.getElementById('image1');
    48   var secondimg = iframeelem.contentDocument.getElementById('image2');
    49   ctx.drawImage(firstimg, 0, 0);
    50   image1second = canvas.toDataURL();
    51   ctx.drawImage(secondimg, 0, 0);
    52   image2second = canvas.toDataURL();
    54   ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have.");
    56   // Sanity check that we actually reloaded.
    57   ok(image1first != image1second, "We got the same images after a force-reload.");
    59   iframeelem.onload = checkReload;
    60   iframeelem.contentWindow.location.reload(false);
    61 }
    63 function checkReload()
    64 {
    65   var iframeelem = document.getElementById('test-iframe');
    66   var canvas = document.getElementById('canvas');
    67   var ctx = canvas.getContext('2d');
    69   var firstimg = iframeelem.contentDocument.getElementById('image1');
    70   var secondimg = iframeelem.contentDocument.getElementById('image2');
    71   ctx.drawImage(firstimg, 0, 0);
    72   image1third = canvas.toDataURL();
    73   ctx.drawImage(secondimg, 0, 0);
    74   image2third = canvas.toDataURL();
    76   ok(image1third == image2third, "We got different images after a reload, but shouldn't have.");
    78   // Sanity check that we actually reloaded properly.
    79   ok(image1second != image1third, "We got the same images after a reload.");
    80   ok(image1first == image1third, "We didn't loop back to the first image.");
    82   SimpleTest.finish();
    83 }
    85 </script>
    86 </pre>
    87 <div id="content"> <!-- style="display: none" -->
    88 <canvas id="canvas" width="100" height="100"> </canvas>
    89 <iframe id="test-iframe" src="bug497665-iframe.html" onload="checkFirst()"></iframe>
    90 </div>
    91 </body>
    92 </html>

mercurial