summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_visited_image_loading_empty.html
blob: 66872547203681a362abdddcc5a58ba442e4140a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=557287
-->
<head>
  <title>Test for Bug 557287</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557287">Mozilla Bug 147777</a>
<pre id="test">
<script type="application/ecmascript" src="visited_image_loading.sjs?reset"></script>
<script type="application/javascript">

/** Test for Bug 557287 **/

SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");

var subdoc, subwin;

window.addEventListener("load", run);

function run()
{
  subwin = window.open("visited_image_loading_frame_empty.html", "_blank");
  subwin.addEventListener("load", function() {
    subdoc = subwin.document;
    setTimeout(check_link_styled, 50);
  });
}

function visitedDependentComputedStyle(win, elem, property) {
  return SpecialPowers.DOMWindowUtils
           .getVisitedDependentComputedStyle(elem, "", property);
}

function check_link_styled()
{
  var vislink = subdoc.getElementById("visited");
  var bgcolor =
    visitedDependentComputedStyle(subwin, vislink, "background-color");
  if (bgcolor == "rgb(128, 0, 128)") {
    // We've done our async :visited processing and restyled accordingly.
    // Make sure that we've actually painted before finishing the test.
    subwin.addEventListener("MozAfterPaint", paint_listener);
    // do something that forces a paint
    subdoc.body.appendChild(subdoc.createTextNode("new text node"));
  } else {
    setTimeout(check_link_styled, 50);
  }
}

function paint_listener(event)
{
  subwin.removeEventListener("MozAfterPaint", paint_listener);
  var s = document.createElement("script");
  s.src = "visited_image_loading.sjs?waitforresult";
  document.body.appendChild(s);
  subwin.close();
}

</script>
</pre>
</body>
</html>