Fri, 16 Jan 2015 18:13:44 +0100
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=671906 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 671906</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=671906">Mozilla Bug 671906</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 snapshotFirst() |
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 = snapshotSecond; |
michael@0 | 30 | iframeelem.src = "http://example.com/tests/image/test/mochitest/bug671906-iframe.html"; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function snapshotSecond() |
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 | // We must have loaded the image again, because the principals for the |
michael@0 | 39 | // loading document are different. |
michael@0 | 40 | [correct, val1, val2] = compareSnapshots(first, second, false); |
michael@0 | 41 | ok(correct, "Image should have changed after changing the iframe's src."); |
michael@0 | 42 | |
michael@0 | 43 | iframeelem.onload = snapshotThird; |
michael@0 | 44 | iframeelem.src = "http://mochi.test:8888/tests/image/test/mochitest/bug671906-iframe.html"; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function snapshotThird() |
michael@0 | 48 | { |
michael@0 | 49 | var iframeelem = document.getElementById('test-iframe'); |
michael@0 | 50 | third = snapshotWindow(iframeelem.contentWindow, false); |
michael@0 | 51 | |
michael@0 | 52 | // We must have loaded the image again, because the principals for the |
michael@0 | 53 | // loading document are different. |
michael@0 | 54 | [correct, val1, val2] = compareSnapshots(second, third, false); |
michael@0 | 55 | ok(correct, "Image should have changed after changing the iframe's src."); |
michael@0 | 56 | |
michael@0 | 57 | // We must have looped back to the first image, because the sjs only sends |
michael@0 | 58 | // one of two images. |
michael@0 | 59 | [correct, val1, val2] = compareSnapshots(first, third, true); |
michael@0 | 60 | ok(correct, "Image should be the same on the third load."); |
michael@0 | 61 | |
michael@0 | 62 | SimpleTest.finish(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | </script> |
michael@0 | 66 | </pre> |
michael@0 | 67 | <div id="content"> <!-- style="display: none" --> |
michael@0 | 68 | <iframe id="test-iframe" src="http://mochi.test:8888/tests/image/test/mochitest/bug671906-iframe.html" onload="snapshotFirst()"></iframe> |
michael@0 | 69 | </div> |
michael@0 | 70 | </body> |
michael@0 | 71 | </html> |