test_bug497665.html (2798B)
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 src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497665">Mozilla Bug 497665</a> 13 <p id="display"></p> 14 <pre id="test"> 15 <script type="application/javascript"> 16 17 var image1first, image2first, image1second, image2second, image1third, image2third; 18 19 SimpleTest.waitForExplicitFinish(); 20 21 function checkFirst() 22 { 23 var iframeelem = document.getElementById('test-iframe'); 24 var canvas = document.getElementById('canvas'); 25 var ctx = canvas.getContext('2d'); 26 27 var firstimg = iframeelem.contentDocument.getElementById('image1'); 28 var secondimg = iframeelem.contentDocument.getElementById('image2'); 29 ctx.drawImage(firstimg, 0, 0); 30 image1first = canvas.toDataURL(); 31 ctx.drawImage(secondimg, 0, 0); 32 image2first = canvas.toDataURL(); 33 34 ok(image1first == image2first, "We got different images, but shouldn't have."); 35 36 iframeelem.onload = checkForceReload; 37 iframeelem.contentWindow.location.reload(true); 38 } 39 40 function checkForceReload() 41 { 42 var iframeelem = document.getElementById('test-iframe'); 43 var canvas = document.getElementById('canvas'); 44 var ctx = canvas.getContext('2d'); 45 46 var firstimg = iframeelem.contentDocument.getElementById('image1'); 47 var secondimg = iframeelem.contentDocument.getElementById('image2'); 48 ctx.drawImage(firstimg, 0, 0); 49 image1second = canvas.toDataURL(); 50 ctx.drawImage(secondimg, 0, 0); 51 image2second = canvas.toDataURL(); 52 53 ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have."); 54 55 // Sanity check that we actually reloaded. 56 ok(image1first != image1second, "We got the same images after a force-reload."); 57 58 iframeelem.onload = checkReload; 59 iframeelem.contentWindow.location.reload(false); 60 } 61 62 function checkReload() 63 { 64 var iframeelem = document.getElementById('test-iframe'); 65 var canvas = document.getElementById('canvas'); 66 var ctx = canvas.getContext('2d'); 67 68 var firstimg = iframeelem.contentDocument.getElementById('image1'); 69 var secondimg = iframeelem.contentDocument.getElementById('image2'); 70 ctx.drawImage(firstimg, 0, 0); 71 image1third = canvas.toDataURL(); 72 ctx.drawImage(secondimg, 0, 0); 73 image2third = canvas.toDataURL(); 74 75 ok(image1third == image2third, "We got different images after a reload, but shouldn't have."); 76 77 SimpleTest.finish(); 78 } 79 80 </script> 81 </pre> 82 <div id="content"> <!-- style="display: none" --> 83 <canvas id="canvas" width="100" height="100"> </canvas> 84 <iframe id="test-iframe" src="bug497665-iframe.html" onload="checkFirst()"></iframe> 85 </div> 86 </body> 87 </html>