2009-03-10 16:51:34 +03:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=481335
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 481335</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
2010-02-24 19:37:03 +03:00
|
|
|
<style type="text/css">
|
|
|
|
a { color:blue; }
|
|
|
|
a:visited { color:red; }
|
|
|
|
</style>
|
2009-03-10 16:51:34 +03:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=481335">Mozilla Bug 481335</a>
|
|
|
|
<p id="display">
|
|
|
|
<a id="t">A link</a>
|
|
|
|
<iframe id="i"></iframe>
|
|
|
|
</p>
|
2018-11-30 05:16:21 +03:00
|
|
|
<p id="newparent" xml:base="http://www.example.com/"></p>
|
2009-03-10 16:51:34 +03:00
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="application/javascript">
|
2009-03-10 16:51:34 +03:00
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
/** Test for Bug 481335 **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2011-04-13 17:35:06 +04:00
|
|
|
var rand = Date.now() + "-" + Math.random();
|
2009-03-10 16:51:34 +03:00
|
|
|
|
|
|
|
is($("t").href, "",
|
|
|
|
"Unexpected href before set");
|
|
|
|
is($("t").href, "",
|
|
|
|
"Unexpected cached href before set");
|
|
|
|
|
|
|
|
$("t").setAttribute("href", rand);
|
2018-11-30 05:16:21 +03:00
|
|
|
is($("t").href,
|
|
|
|
window.location.href.replace(/test_bug481335.xhtml([\?].*)?/, rand),
|
2009-03-10 16:51:34 +03:00
|
|
|
"Unexpected href after set");
|
2018-11-30 05:16:21 +03:00
|
|
|
is($("t").href,
|
|
|
|
window.location.href.replace(/test_bug481335.xhtml([\?].*)?/, rand),
|
2009-03-10 16:51:34 +03:00
|
|
|
"Unexpected cached href after set");
|
2010-02-24 19:37:03 +03:00
|
|
|
const unvisitedColor = "rgb(0, 0, 255)";
|
|
|
|
const visitedColor = "rgb(255, 0, 0)";
|
2009-03-10 16:51:34 +03:00
|
|
|
|
2010-02-24 19:37:03 +03:00
|
|
|
let tests = testIterator();
|
|
|
|
function continueTest() {
|
|
|
|
tests.next();
|
2009-04-04 08:14:59 +04:00
|
|
|
}
|
|
|
|
|
2010-02-24 19:37:03 +03:00
|
|
|
function checkLinkColor(aElmId, aExpectedColor, aMessage) {
|
|
|
|
// Because link coloring is asynchronous, we wait until we get the right
|
|
|
|
// result, or we will time out (resulting in a failure).
|
2010-04-03 05:58:25 +04:00
|
|
|
function getColor() {
|
2013-09-11 12:51:09 +04:00
|
|
|
var utils = SpecialPowers.getDOMWindowUtils(window);
|
2010-04-03 05:58:25 +04:00
|
|
|
return utils.getVisitedDependentComputedStyle($(aElmId), "", "color");
|
|
|
|
}
|
|
|
|
while (getColor() != aExpectedColor) {
|
2011-04-20 13:45:54 +04:00
|
|
|
setTimeout(continueTest, 0);
|
2010-02-24 19:37:03 +03:00
|
|
|
return false;
|
|
|
|
}
|
2010-04-03 05:58:25 +04:00
|
|
|
is(getColor(), aExpectedColor, aMessage);
|
2010-02-24 19:37:03 +03:00
|
|
|
return true;
|
2009-03-10 16:51:34 +03:00
|
|
|
}
|
|
|
|
|
2016-12-01 12:11:32 +03:00
|
|
|
function* testIterator() {
|
2010-02-24 19:37:03 +03:00
|
|
|
// After first load
|
2009-03-10 16:51:34 +03:00
|
|
|
$("newparent").appendChild($("t"));
|
|
|
|
is($("t").href, "http://www.example.com/" + rand,
|
|
|
|
"Unexpected href after move");
|
|
|
|
is($("t").href, "http://www.example.com/" + rand,
|
|
|
|
"Unexpected cached href after move");
|
2010-02-24 19:37:03 +03:00
|
|
|
while (!checkLinkColor("t", unvisitedColor, "Should be unvisited now"))
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
|
|
|
|
$("i").src = $("t").href;
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
|
|
|
|
// After second load
|
|
|
|
while (!checkLinkColor("t", visitedColor, "Should be visited now"))
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
$("t").pathname = rand;
|
|
|
|
while (!checkLinkColor("t", visitedColor,
|
|
|
|
"Should still be visited after setting pathname to its existing value")) {
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
}
|
|
|
|
/* TODO uncomment this test with the landing of bug 534526. See
|
|
|
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=461199#c167
|
|
|
|
$("t").pathname += "x";
|
|
|
|
while (!checkLinkColor("t", unvisitedColor,
|
|
|
|
"Should not be visited after changing pathname")) {
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
}
|
|
|
|
$("t").pathname = $("t").pathname;
|
|
|
|
while (!checkLinkColor("t", unvisitedColor,
|
|
|
|
"Should not be visited after setting unvisited pathname to existing value")) {
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
}
|
|
|
|
*/
|
2009-03-10 16:51:34 +03:00
|
|
|
|
|
|
|
$("i").src = $("t").href;
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
|
|
|
|
// After third load
|
|
|
|
while (!checkLinkColor("t", visitedColor,
|
|
|
|
"Should be visited now after third load")) {
|
2013-07-11 01:52:14 +04:00
|
|
|
yield undefined;
|
2010-02-24 19:37:03 +03:00
|
|
|
}
|
|
|
|
SimpleTest.finish();
|
2009-03-10 16:51:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
addLoadEvent(function() {
|
2010-02-24 19:37:03 +03:00
|
|
|
$("i").onload = continueTest;
|
2009-03-10 16:51:34 +03:00
|
|
|
$("i").src = $("t").href;
|
|
|
|
});
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|