Backed out changeset 2bd2f67e8f5e

This commit is contained in:
Shawn Wilsher 2010-02-18 09:52:30 -08:00
parent 855db8485f
commit 6e0cbcb294
2 changed files with 58 additions and 86 deletions

View File

@ -56,7 +56,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=209275
<svg width="5cm" height="3cm" viewBox="0 0 5 3" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="" id="ellipselink">
<a xlink:href="http://www.w3.org" id="ellipselink">
<ellipse cx="2.5" cy="1.5" rx="2" ry="1" id="ellipse" />
</a>
</svg>
@ -91,10 +91,6 @@ function setXlinkHref(elem, href) {
elem.setAttributeNS("http://www.w3.org/1999/xlink", "href", href);
}
function continueTest() {
gGen.next();
}
var iframe = document.getElementById("iframe");
var iframeCw = iframe.contentWindow;
@ -102,13 +98,29 @@ function run() {
var iframe = document.getElementById("iframe");
var iframeCw = iframe.contentWindow;
// First, set the visited/unvisited link/ellipse colors.
const unvisitedColor = "rgb(0, 0, 238)";
const visitedColor = "rgb(85, 26, 139)";
const unvisitedFill = "rgb(0, 0, 255)";
const visitedFill = "rgb(128, 0, 128)";
// First, get the visited/unvisited link/ellipse colors.
var unvisitedColor;
var visitedColor;
var unvisitedFill;
var visitedFill;
const rand = Date.now() + "-" + Math.random();
var rand = Date.now() + "-" + Math.random();
// Set colorlink and ellipselink's hrefs
$("colorlink").href = rand;
setXlinkHref($("ellipselink"), rand);
unvisitedColor = getColor($("colorlink"));
unvisitedFill = getFill($("ellipse"));
// Set the link's href to our current location so we can get the visited link
// color.
$("colorlink").href = document.location;
setXlinkHref($("ellipselink"), document.location);
visitedColor = getColor($("colorlink"));
visitedFill = getFill($("ellipse"));
isnot(visitedColor, unvisitedColor,
"visited/unvisited link colors are the same?");
isnot(visitedFill, unvisitedFill,
"visited/unvisited ellipse fill colors are the same?");
// Now we can start the tests in earnest.
@ -119,11 +131,11 @@ function run() {
// Set colorlink's href so we can check that it changes colors after we
// change the base href.
$('colorlink').href = "http://example.com/" + rand;
setXlinkHref($("ellipselink"), "http://example.com/" + rand);
setXlinkHref($("ellipse"), "http://example.com/" + rand);
// Load http://example.com/${rand} into an iframe so we can test that changing
// the document's base changes the visitedness of our links.
iframe.onload = continueTest;
iframe.onload = function() { gGen.next(); };
iframeCw.location = "http://example.com/" + rand;
yield; // wait for onload to fire.
@ -145,19 +157,9 @@ function run() {
is(link5.href, "http://example.com/#", "link 5 test 2");
// Were colorlink's color and ellipse's fill updated appropriately?
// Because link coloring is asynchronous, we wait until it is updated (or we
// timeout and fail anyway).
while (getColor($('colorlink')) != visitedColor) {
setTimeout(continueTest, 10);
yield;
}
is(getColor($('colorlink')), visitedColor,
"Wrong link color after base change.");
while (getFill($('ellipselink')) != visitedFill) {
setTimeout(continueTest, 10);
yield;
}
is(getFill($('ellipselink')), visitedFill,
is(getFill($('ellipse')), visitedFill,
"Wrong ellipse fill after base change.");
$('base1').href = "foo/";

View File

@ -7,10 +7,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=481335
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<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">
a { color:blue; }
a:visited { color:red; }
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=481335">Mozilla Bug 481335</a>
@ -21,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=481335
<p id="newparent" xml:base="http://www.example.com/"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript;version=1.7">
<script type="application/javascript">
<![CDATA[
/** Test for Bug 481335 **/
@ -35,80 +31,54 @@ is($("t").href, "",
$("t").setAttribute("href", rand);
is($("t").href,
window.location.href.replace(/test_bug481335.xhtml([\?].*)?/, rand),
window.location.href.replace(/test_bug481335.xhtml/, rand),
"Unexpected href after set");
is($("t").href,
window.location.href.replace(/test_bug481335.xhtml([\?].*)?/, rand),
window.location.href.replace(/test_bug481335.xhtml/, rand),
"Unexpected cached href after set");
const unvisitedColor = "rgb(0, 0, 255)";
const visitedColor = "rgb(255, 0, 0)";
var unvisitedColor = document.defaultView.getComputedStyle($("t"), "").color;
var visitedColor;
let tests = testIterator();
function continueTest() {
tests.next();
function afterThirdLoad() {
is(document.defaultView.getComputedStyle($("t"), "").color, visitedColor,
"Should be visited now after third load");
SimpleTest.finish();
}
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).
var getCS = document.defaultView.getComputedStyle;
while (getCS($(aElmId), "").color != aExpectedColor) {
setTimeout(continueTest, 10);
return false;
}
is(getCS($(aElmId), "").color, aExpectedColor, aMessage);
return true;
function afterSecondLoad() {
is(document.defaultView.getComputedStyle($("t"), "").color, visitedColor,
"Should be visited now");
$("t").pathname = rand;
is(document.defaultView.getComputedStyle($("t"), "").color, visitedColor,
"Should still be visited after setting pathname to its existing value");
$("t").pathname += "x";
isnot(document.defaultView.getComputedStyle($("t"), "").color, visitedColor,
"Should not be visited after changing pathname");
$("t").pathname = $("t").pathname;
isnot(document.defaultView.getComputedStyle($("t"), "").color, visitedColor,
"Should not be visited after setting unvisited pathname to existing value");
$("i").onload = afterThirdLoad;
$("i").src = $("t").href;
}
function testIterator() {
// After first load
function afterFirstLoad() {
visitedColor = document.defaultView.getComputedStyle($("t"), "").color;
isnot(visitedColor, unvisitedColor, "Why are the colors the same?");
$("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");
while (!checkLinkColor("t", unvisitedColor, "Should be unvisited now"))
yield;
is(document.defaultView.getComputedStyle($("t"), "").color, unvisitedColor,
"Should be unvisited now");
$("i").onload = afterSecondLoad;
$("i").src = $("t").href;
yield;
// After second load
while (!checkLinkColor("t", visitedColor, "Should be visited now"))
yield;
$("t").pathname = rand;
while (!checkLinkColor("t", visitedColor,
"Should still be visited after setting pathname to its existing value")) {
yield;
}
/* 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")) {
yield;
}
$("t").pathname = $("t").pathname;
while (!checkLinkColor("t", unvisitedColor,
"Should not be visited after setting unvisited pathname to existing value")) {
yield;
}
*/
$("i").src = $("t").href;
yield;
// After third load
while (!checkLinkColor("t", visitedColor,
"Should be visited now after third load")) {
yield;
}
SimpleTest.finish();
yield;
}
addLoadEvent(function() {
$("i").onload = continueTest;
$("i").onload = afterFirstLoad;
$("i").src = $("t").href;
});
]]>