4 https://bugzilla.mozilla.org/show_bug.cgi?id=147777
7 <title>Test for visited link coloring pref Bug
147777</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script src=
"/tests/SimpleTest/WindowSnapshot.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <style type=
"text/css">
13 :link
{ float: left
; }
15 :visited
{ float: right
; }
20 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=147777">Mozilla Bug
147777</a>
21 <iframe id=
"iframe" src=
"visited-pref-iframe.html" style=
"width: 10em; height: 5em"></iframe>
23 <script type=
"application/javascript">
24 /** Test for Bug
147777 **/
26 function reinsert_node(e) {
27 var sib = e.nextSibling;
28 var par = e.parentNode;
30 par.insertBefore(e, sib);
35 return SpecialPowers.getBoolPref(
"layout.css.visited_links_enabled");
38 function snapshotsEqual(snap1, snap2)
40 return compareSnapshots(snap1, snap2, true)[
0];
43 SimpleTest.waitForExplicitFinish();
44 SimpleTest.requestFlakyTimeout(
"untriaged");
45 window.addEventListener(
"load", step1);
47 var iframe, subdoc, subwin;
52 var unvisref; // reference image for unvisited style
56 is(get_pref(), true,
"pref defaults to true");
58 iframe = document.getElementById(
"iframe");
59 subdoc = iframe.contentDocument;
60 subwin = iframe.contentWindow;
61 link = subdoc.getElementById(
"link");
63 unvisref = snapshotWindow(subwin, false);
65 // Now set the href of the link to a location that's actually visited.
66 link.href = top.location;
70 // And wait for the link to get restyled when the history lets us
71 // know it is (asynchronously).
72 setTimeout(poll_for_visited_style,
100);
75 function poll_for_visited_style()
77 var snapshot = snapshotWindow(subwin, false);
78 if (snapshotsEqual(unvisref, snapshot)) {
79 // hasn't been styled yet
80 setTimeout(poll_for_visited_style,
100);
82 // If it never gets styled correctly, this test will fail because
83 // this loop will never complete.
86 timeout =
3 * Math.max(end - start,
300);
87 SpecialPowers.pushPrefEnv({
"set":[[
"layout.css.visited_links_enabled", false]]}, step2);
93 // we don't handle dynamic changes of this pref; it only takes effect
94 // when a new page loads
97 setTimeout(step3, timeout);
102 var snapshot = snapshotWindow(subwin, false);
103 ok(snapshotsEqual(unvisref, snapshot),
104 ":visited selector does not apply given false preference");