Bug 1090555 - Fix visited link test in test_animations_omta.html to wait for visited link coloring properly. r=birtles

This patch contains two changes:
 (1) The addition of refVisitedLink and the use of
     waitForVisitedLinkColoring() on it.
 (2) Changing the URL of the visited lisks (both visitedLink and
     refVisitedLink) from "" to window.top.location.href, since the
     former doesn't work for Android mochitests while it does work on
     Linux mochitest-e10s.

I tested locally that without the patch I get the failures, and with the
patch the failures go away, using:
./mach mochitest-plain --e10s --setpref layers.acceleration.force-enabled=true --setpref layers.offmainthreadcomposition.async-animations=true layout/style/test/test_animations_omta.html

Further, when running (and passing), I checked that
waitForVisitedLinkColoring() does go through one setTimeout cycle.

Also, I tested that if I effectively revert
https://hg.mozilla.org/mozilla-central/rev/d13154302d77 by changing the
third parameter to the GetContext call in
nsStyleSet::ResolveStyleWithReplacement to be nullptr instead of
visitedRuleNode, I get the failure:
TEST-UNEXPECTED-FAIL | layout/style/test/test_animations_omta.html | visited link background color after animation-only flush - got rgb(255, 255, 0), expected rgb(0, 0, 255)
which confirms that the test is still testing what it was designed to
test.
This commit is contained in:
L. David Baron 2015-03-24 19:13:47 -07:00
Родитель 6781d5a34e
Коммит 313a709b74
3 изменённых файлов: 39 добавлений и 17 удалений

Просмотреть файл

@ -676,3 +676,20 @@ function waitForPaintsFlushed() {
waitForAllPaintsFlushed(resolve);
});
}
function waitForVisitedLinkColoring(visitedLink, waitProperty, waitValue) {
function checkLink(resolve) {
if (SpecialPowers.DOMWindowUtils
.getVisitedDependentComputedStyle(visitedLink, "", waitProperty) ==
waitValue) {
// Our link has been styled as visited. Resolve.
resolve(true);
} else {
// Our link is not yet styled as visited. Poll for completion.
setTimeout(checkLink, 0, resolve);
}
}
return new Promise(function(resolve, reject) {
checkLink(resolve);
});
}

Просмотреть файл

@ -37,7 +37,6 @@ generated-files = css_properties.js
[test_animations.html]
skip-if = toolkit == 'android'
[test_animations_omta.html]
skip-if = buildapp == 'mulet'
[test_animations_omta_start.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # bug 1041017
[test_animations_pausing.html]

Просмотреть файл

@ -152,8 +152,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=964646
background-color: white;
}
#visitedLink:link { background-color: yellow }
#visitedLink:visited { background-color: blue }
.visitedLink:link { background-color: yellow }
.visitedLink:visited { background-color: blue }
@keyframes opacitymid {
0% { opacity: 0.2 }
@ -2022,38 +2022,43 @@ addAsyncAnimTest(function *() {
// Bug 996796 patch 12 - test for correct visited styles during
// animation-only style flush.
addAsyncAnimTest(function *() {
var isb2g = SpecialPowers.Services.appinfo.name == "B2G";
if (isb2g) {
todo(false, "no global history on B2G; can't run test");
return;
}
var div1 = document.createElement("div");
div1.classList.add("target");
div1.style.height = "10px";
div1.style.animation = "anim2 linear 1s";
var visitedLink = document.createElement("a");
visitedLink.setAttribute("href", "");
visitedLink.setAttribute("id", "visitedLink");
visitedLink.setAttribute("href", window.top.location.href);
visitedLink.classList.add("visitedLink");
visitedLink.classList.add("target");
visitedLink.style.display = "block";
visitedLink.style.height = "10px";
visitedLink.style.animation = "anim2 linear 1s";
var refVisitedLink = document.createElement("a");
refVisitedLink.setAttribute("href", window.top.location.href);
refVisitedLink.classList.add("visitedLink");
gDisplay.appendChild(div1);
gDisplay.appendChild(visitedLink);
gDisplay.appendChild(refVisitedLink);
// Wait for animations to start and for visited link coloring.
// Wait for visited link coloring.
yield waitForVisitedLinkColoring(refVisitedLink,
"background-color", "rgb(0, 0, 255)");
// Wait for animations to start.
yield waitForPaintsFlushed();
var bgColor = SpecialPowers.DOMWindowUtils
.getVisitedDependentComputedStyle(visitedLink, "", "background-color");
var isb2g = SpecialPowers.Services.appinfo.name == "B2G";
// No global history in B2G.
(isb2g ? todo_is : is)(bgColor, "rgb(0, 0, 255)",
"initial visited link background color");
if (isb2g) {
// The above failure makes the rest of the test pointless.
div1.remove();
visitedLink.remove();
return;
}
is(bgColor, "rgb(0, 0, 255)", "initial visited link background color");
advance_clock(250);
@ -2070,6 +2075,7 @@ addAsyncAnimTest(function *() {
div1.remove();
visitedLink.remove();
refVisitedLink.remove();
});
/*