test_bug671906.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=671906
  5. -->
  6. <head>
  7. <title>Test for Bug 671906</title>
  8. <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
  11. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  12. </head>
  13. <body>
  14. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=671906">Mozilla Bug 671906</a>
  15. <p id="display"></p>
  16. <pre id="test">
  17. <script type="application/javascript">
  18. var first, second, third;
  19. var correct, val1, val2;
  20. SimpleTest.waitForExplicitFinish();
  21. function snapshotFirst()
  22. {
  23. var iframeelem = document.getElementById('test-iframe');
  24. first = snapshotWindow(iframeelem.contentWindow, false);
  25. iframeelem.onload = snapshotSecond;
  26. iframeelem.src = "http://example.com/tests/image/test/mochitest/bug671906-iframe.html";
  27. }
  28. function snapshotSecond()
  29. {
  30. var iframeelem = document.getElementById('test-iframe');
  31. second = snapshotWindow(iframeelem.contentWindow, false);
  32. // We must have loaded the image again, because the principals for the
  33. // loading document are different.
  34. [correct, val1, val2] = compareSnapshots(first, second, false);
  35. ok(correct, "Image should have changed after changing the iframe's src.");
  36. iframeelem.onload = snapshotThird;
  37. iframeelem.src = "http://mochi.test:8888/tests/image/test/mochitest/bug671906-iframe.html";
  38. }
  39. function snapshotThird()
  40. {
  41. var iframeelem = document.getElementById('test-iframe');
  42. third = snapshotWindow(iframeelem.contentWindow, false);
  43. // We must have loaded the image again, because the principals for the
  44. // loading document are different.
  45. [correct, val1, val2] = compareSnapshots(second, third, false);
  46. ok(correct, "Image should have changed after changing the iframe's src.");
  47. // We must have looped back to the first image, because the sjs only sends
  48. // one of two images.
  49. [correct, val1, val2] = compareSnapshots(first, third, true);
  50. ok(correct, "Image should be the same on the third load.");
  51. SimpleTest.finish();
  52. }
  53. </script>
  54. </pre>
  55. <div id="content"> <!-- style="display: none" -->
  56. <iframe id="test-iframe" src="http://mochi.test:8888/tests/image/test/mochitest/bug671906-iframe.html" onload="snapshotFirst()"></iframe>
  57. </div>
  58. </body>
  59. </html>