image/test/mochitest/test_bug497665.html

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:5deb8db5e9da
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">
17
18 var image1first, image2first, image1second, image2second, image1third, image2third;
19
20 SimpleTest.waitForExplicitFinish();
21
22 function checkFirst()
23 {
24 var iframeelem = document.getElementById('test-iframe');
25 var canvas = document.getElementById('canvas');
26 var ctx = canvas.getContext('2d');
27
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();
34
35 ok(image1first == image2first, "We got different images, but shouldn't have.");
36
37 iframeelem.onload = checkForceReload;
38 iframeelem.contentWindow.location.reload(true);
39 }
40
41 function checkForceReload()
42 {
43 var iframeelem = document.getElementById('test-iframe');
44 var canvas = document.getElementById('canvas');
45 var ctx = canvas.getContext('2d');
46
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();
53
54 ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have.");
55
56 // Sanity check that we actually reloaded.
57 ok(image1first != image1second, "We got the same images after a force-reload.");
58
59 iframeelem.onload = checkReload;
60 iframeelem.contentWindow.location.reload(false);
61 }
62
63 function checkReload()
64 {
65 var iframeelem = document.getElementById('test-iframe');
66 var canvas = document.getElementById('canvas');
67 var ctx = canvas.getContext('2d');
68
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();
75
76 ok(image1third == image2third, "We got different images after a reload, but shouldn't have.");
77
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.");
81
82 SimpleTest.finish();
83 }
84
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