2008-10-21 00:15:03 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=147777
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for visited link coloring pref Bug 147777</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
2008-10-21 00:15:03 -07:00
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
<style type="text/css">
|
|
|
|
|
|
|
|
:link { float: left; }
|
|
|
|
|
|
|
|
:visited { float: right; }
|
|
|
|
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=147777">Mozilla Bug 147777</a>
|
|
|
|
<p id="display"><a id="mylink" href="test_visited_pref.html">link to this page</a></p>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 147777 **/
|
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
// NOTE: this test will fail when ran by itself because the URL is different!
|
|
|
|
|
2008-10-21 00:15:03 -07:00
|
|
|
function reinsert_node(e) {
|
|
|
|
var sib = e.nextSibling;
|
|
|
|
var par = e.parentNode;
|
|
|
|
par.removeChild(e);
|
|
|
|
par.insertBefore(e, sib);
|
|
|
|
}
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefService);
|
|
|
|
var dispBranch = prefService.getBranch("layout.css.");
|
|
|
|
|
|
|
|
function get_pref()
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
return dispBranch.getBoolPref("visited_links_enabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_pref(val)
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
dispBranch.setBoolPref("visited_links_enabled", val);
|
|
|
|
}
|
|
|
|
|
|
|
|
is(get_pref(), true, "pref defaults to true");
|
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
// Link coloring is asynchronous (and non-deterministic), so we wait until it
|
|
|
|
// changes.
|
|
|
|
var thread = Components.classes["@mozilla.org/thread-manager;1"].
|
|
|
|
getService(Components.interfaces.nsIThreadManager).
|
|
|
|
mainThread;
|
2008-10-21 00:15:03 -07:00
|
|
|
var link = document.getElementById("mylink");
|
2010-02-24 08:37:03 -08:00
|
|
|
var cs;
|
|
|
|
var start = Date.now();
|
|
|
|
do {
|
|
|
|
while (thread.hasPendingEvents())
|
|
|
|
thread.processNextEvent(false);
|
|
|
|
cs = getComputedStyle(link, "");
|
|
|
|
} while(cs.cssFloat != "right");
|
|
|
|
var end = Date.now();
|
2008-10-21 00:15:03 -07:00
|
|
|
is(cs.cssFloat, "right", ":visited selector applies given default preferences");
|
|
|
|
|
|
|
|
set_pref(false);
|
|
|
|
|
|
|
|
// we don't handle dynamic changes of this pref; it only takes effect
|
|
|
|
// when a new page loads
|
|
|
|
reinsert_node(link);
|
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
// Wait a while to make sure we don't update the style on our reinserted node.
|
|
|
|
setTimeout(function() {
|
|
|
|
is(cs.cssFloat, "left", ":visited selector does not apply given false preference");
|
|
|
|
|
|
|
|
// Set the pref back for the rest of the tests.
|
|
|
|
set_pref(true);
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}, 10 * Math.max(end - start, 100));
|
2008-10-21 00:15:03 -07:00
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2008-10-21 00:15:03 -07:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|