image/test/mochitest/test_bug89419-2.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=89419
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 89419</title>
michael@0 8 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 89419</a>
michael@0 15 <p id="display"></p>
michael@0 16 <pre id="test">
michael@0 17 <script type="application/javascript">
michael@0 18
michael@0 19 var first, second, third;
michael@0 20 var correct, val1, val2;
michael@0 21
michael@0 22 SimpleTest.waitForExplicitFinish();
michael@0 23
michael@0 24 function checkFirst()
michael@0 25 {
michael@0 26 var iframeelem = document.getElementById('test-iframe');
michael@0 27 first = snapshotWindow(iframeelem.contentWindow, false);
michael@0 28
michael@0 29 iframeelem.onload = checkSecond;
michael@0 30 iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
michael@0 31 }
michael@0 32
michael@0 33 function checkSecond()
michael@0 34 {
michael@0 35 var iframeelem = document.getElementById('test-iframe');
michael@0 36 second = snapshotWindow(iframeelem.contentWindow, false);
michael@0 37
michael@0 38 // Check that we actually reloaded.
michael@0 39 [correct, val1, val2] = compareSnapshots(first, second, false);
michael@0 40 ok(correct, "Image should have changed after the first reload.");
michael@0 41
michael@0 42 iframeelem.onload = checkThird;
michael@0 43 iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
michael@0 44 }
michael@0 45
michael@0 46 function checkThird()
michael@0 47 {
michael@0 48 var iframeelem = document.getElementById('test-iframe');
michael@0 49 third = snapshotWindow(iframeelem.contentWindow, false);
michael@0 50
michael@0 51 // Check that we actually reloaded.
michael@0 52 [correct, val1, val2] = compareSnapshots(second, third, false);
michael@0 53 ok(correct, "Image should have changed after the second reload.");
michael@0 54
michael@0 55 // Make sure we looped back to the first image.
michael@0 56 [correct, val1, val2] = compareSnapshots(first, third, true);
michael@0 57 ok(correct, "Third image should match first image.");
michael@0 58
michael@0 59 SimpleTest.finish();
michael@0 60 }
michael@0 61
michael@0 62 </script>
michael@0 63 </pre>
michael@0 64 <div id="content"> <!-- style="display: none" -->
michael@0 65 <iframe id="test-iframe" src="bug89419-iframe.html" onload="checkFirst()"></iframe>
michael@0 66 </div>
michael@0 67 </body>
michael@0 68 </html>

mercurial