tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_visited_image_loading.html (1933B)


      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 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 <pre id="test">
     14 <script type="application/ecmascript" src="visited_image_loading.sjs?reset"></script>
     15 <script type="application/javascript">
     16 
     17 /** Test for Bug 557287 */
     18 
     19 SimpleTest.waitForExplicitFinish();
     20 SimpleTest.requestFlakyTimeout("untriaged");
     21 
     22 var subdoc, subwin;
     23 
     24 window.addEventListener("load", run);
     25 
     26 function run()
     27 {
     28  subwin = window.open("visited_image_loading_frame.html", "_blank");
     29  subwin.addEventListener("load", function() {
     30    subdoc = subwin.document;
     31    setTimeout(check_link_styled, 50);
     32  });
     33 }
     34 
     35 function visitedDependentComputedStyle(win, elem, property) {
     36  return SpecialPowers.DOMWindowUtils
     37           .getVisitedDependentComputedStyle(elem, "", property);
     38 }
     39 
     40 function check_link_styled()
     41 {
     42  var vislink = subdoc.getElementById("visited");
     43  var bgcolor =
     44    visitedDependentComputedStyle(subwin, vislink, "background-color");
     45  if (bgcolor == "rgb(128, 0, 128)") {
     46    // We've done our async :visited processing and restyled accordingly.
     47    // Make sure that we've actually painted before finishing the test.
     48    subwin.addEventListener("MozAfterPaint", paint_listener);
     49    // do something that forces a paint
     50    subdoc.body.appendChild(subdoc.createTextNode("new text node"));
     51  } else {
     52    setTimeout(check_link_styled, 50);
     53  }
     54 }
     55 
     56 function paint_listener(event)
     57 {
     58  subwin.removeEventListener("MozAfterPaint", paint_listener);
     59  var s = document.createElement("script");
     60  s.src = "visited_image_loading.sjs?waitforresult";
     61  document.body.appendChild(s);
     62  subwin.close();
     63 }
     64 
     65 </script>
     66 </pre>
     67 </body>
     68 </html>