test_visited_image_loading.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=557287
  5. -->
  6. <head>
  7. <title>Test for Bug 557287</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557287">Mozilla Bug 147777</a>
  13. <iframe id="display" src="visited_image_loading_frame.html"></iframe>
  14. <pre id="test">
  15. <script type="application/ecmascript" src="visited_image_loading.sjs?reset"></script>
  16. <script type="application/javascript">
  17. /** Test for Bug 557287 **/
  18. SimpleTest.waitForExplicitFinish();
  19. SimpleTest.requestFlakyTimeout("untriaged");
  20. var subdoc, subwin;
  21. window.addEventListener("load", run, false);
  22. function run()
  23. {
  24. var frame = document.getElementById("display");
  25. subdoc = frame.contentDocument;
  26. subwin = frame.contentWindow;
  27. setTimeout(check_link_styled, 50);
  28. }
  29. function visitedDependentComputedStyle(win, elem, property) {
  30. return SpecialPowers.DOMWindowUtils
  31. .getVisitedDependentComputedStyle(elem, "", property);
  32. }
  33. function check_link_styled()
  34. {
  35. var vislink = subdoc.getElementById("visited");
  36. var bgcolor =
  37. visitedDependentComputedStyle(subwin, vislink, "background-color");
  38. if (bgcolor == "rgb(128, 0, 128)") {
  39. // We've done our async :visited processing and restyled accordingly.
  40. // Make sure that we've actually painted before finishing the test.
  41. subwin.addEventListener("MozAfterPaint", paint_listener, false);
  42. // do something that forces a paint
  43. subdoc.body.appendChild(subdoc.createTextNode("new text node"));
  44. } else {
  45. setTimeout(check_link_styled, 50);
  46. }
  47. }
  48. function paint_listener(event)
  49. {
  50. subwin.removeEventListener("MozAfterPaint", paint_listener, false);
  51. var s = document.createElement("script");
  52. s.src = "visited_image_loading.sjs?waitforresult";
  53. document.body.appendChild(s);
  54. }
  55. </script>
  56. </pre>
  57. </body>
  58. </html>