test_srcdoc-2.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!doctype html>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=802895
  5. -->
  6. <head>
  7. <title>Test session history for srcdoc iframes introduced in bug 802895</title>
  8. <script src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=802895">Mozilla Bug 802895</a>
  13. <iframe id="pframe" name="pframe" src="file_srcdoc-2.html"></iframe>
  14. <pre id="test">
  15. <script>
  16. SimpleTest.waitForExplicitFinish();
  17. var pframe = $("pframe");
  18. //disable bfcache
  19. pframe.contentWindow.addEventListener("unload", function () { }, false);
  20. var loadState = 0;
  21. pframe.onload = function () {
  22. SimpleTest.executeSoon(function () {
  23. var pDoc = pframe.contentDocument;
  24. if (loadState == 0) {
  25. var div = pDoc.createElement("div");
  26. div.id = "modifyCheck";
  27. div.innerHTML = "hello again";
  28. pDoc.body.appendChild(div);
  29. ok(pDoc.getElementById("modifyCheck"), "Child element not created");
  30. pframe.src = "about:blank";
  31. loadState = 1;
  32. }
  33. else if (loadState == 1) {
  34. loadState = 2;
  35. window.history.back();
  36. }
  37. else if (loadState == 2) {
  38. ok(!pDoc.getElementById("modifyCheck"), "modifyCheck element shouldn't be present");
  39. is(pDoc.getElementById("iframe").contentDocument.body.innerHTML,
  40. "Hello World", "srcdoc iframe not present");
  41. SimpleTest.finish();
  42. }
  43. })
  44. };
  45. </script>
  46. </pre>
  47. </body>
  48. </html>