mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
219ed0cc06
The old name no longer makes sense, since it no longer exports an spawn_task symbol, and add_task is what we really care about. MozReview-Commit-ID: IE7B8Czv8DH --HG-- rename : testing/mochitest/tests/SimpleTest/SpawnTask.js => testing/mochitest/tests/SimpleTest/AddTask.js extra : rebase_source : 03bca5aa69a7625a49b4455a6c96ce4c59de3a5a
116 lines
3.5 KiB
HTML
116 lines
3.5 KiB
HTML
<!doctype html>
|
|
<head>
|
|
<meta charset=utf-8>
|
|
<title>Tests restyles in smil animation</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script src="/tests/SimpleTest/AddTask.js"></script>
|
|
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div id="target-div">
|
|
<svg>
|
|
<rect id="svg-rect" width="100%" height="100%" fill="lime"/>
|
|
</svg>
|
|
</div>
|
|
|
|
<script>
|
|
"use strict";
|
|
|
|
function waitForAnimationFrames(frameCount) {
|
|
return new Promise(function(resolve, reject) {
|
|
function handleFrame() {
|
|
if (--frameCount <= 0) {
|
|
resolve();
|
|
} else {
|
|
window.requestAnimationFrame(handleFrame); // wait another frame
|
|
}
|
|
}
|
|
window.requestAnimationFrame(handleFrame);
|
|
});
|
|
}
|
|
|
|
function observeStyling(frameCount) {
|
|
var Ci = SpecialPowers.Ci;
|
|
var docShell =
|
|
SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
.QueryInterface(Ci.nsIDocShell);
|
|
|
|
docShell.recordProfileTimelineMarkers = true;
|
|
docShell.popProfileTimelineMarkers();
|
|
|
|
return new Promise(function(resolve) {
|
|
return waitForAnimationFrames(frameCount).then(function() {
|
|
var markers = docShell.popProfileTimelineMarkers();
|
|
docShell.recordProfileTimelineMarkers = false;
|
|
var stylingMarkers = markers.filter(function(marker, index) {
|
|
return marker.name == 'Styles' && marker.isAnimationOnly;
|
|
});
|
|
resolve(stylingMarkers);
|
|
});
|
|
});
|
|
}
|
|
|
|
function ensureElementRemoval(aElement) {
|
|
return new Promise(function(resolve) {
|
|
aElement.remove();
|
|
waitForAllPaintsFlushed(resolve);
|
|
});
|
|
}
|
|
|
|
function waitForPaintFlushed() {
|
|
return new Promise(function(resolve) {
|
|
waitForAllPaintsFlushed(resolve);
|
|
});
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
add_task(async function smil_is_in_display_none_subtree() {
|
|
await waitForPaintFlushed();
|
|
|
|
var animate =
|
|
document.createElementNS("http://www.w3.org/2000/svg", "animate");
|
|
animate.setAttribute("attributeType", "XML");
|
|
animate.setAttribute("attributeName", "fill");
|
|
animate.setAttribute("values", "red;lime");
|
|
animate.setAttribute("dur", "1s");
|
|
animate.setAttribute("repeatCount", "indefinite");
|
|
document.getElementById("svg-rect").appendChild(animate);
|
|
|
|
await waitForPaintFlushed();
|
|
|
|
var displayMarkers = await observeStyling(5);
|
|
// FIXME: Bug 866411: SMIL animations sometimes skip restyles when the target
|
|
// element is newly associated with an nsIFrame.
|
|
ok(displayMarkers.length == 5 || displayMarkers.length == 4,
|
|
`should restyle in most frames (got ${displayMarkers.length} restyles`
|
|
+ ' over five frames, expected 4~5)');
|
|
|
|
var div = document.getElementById("target-div");
|
|
|
|
div.style.display = "none";
|
|
getComputedStyle(div).display;
|
|
await waitForPaintFlushed();
|
|
|
|
var displayNoneMarkers = await observeStyling(5);
|
|
is(displayNoneMarkers.length, 0, "should never restyle if display:none");
|
|
|
|
div.style.display = "";
|
|
getComputedStyle(div).display;
|
|
await waitForPaintFlushed();
|
|
|
|
var displayAgainMarkers = await observeStyling(5);
|
|
// FIXME: Bug 866411: SMIL animations sometimes skip restyles when the target
|
|
// element is newly associated with an nsIFrame.
|
|
ok(displayMarkers.length == 5 || displayMarkers.length == 4,
|
|
`should restyle again (got ${displayMarkers.length} restyles over`
|
|
+ ' five frames, expected 4~5)');
|
|
|
|
await ensureElementRemoval(animate);
|
|
});
|
|
</script>
|
|
</body>
|