Bug 1190881 - Part 3. mochitest for svg css animation.
MozReview-Commit-ID: JchZk3FrZce
new file mode 100644
--- /dev/null
+++ b/image/test/mochitest/lime-css-anim-100x100.svg
@@ -0,0 +1,19 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
+ width="100" height="100">
+ <defs>
+ <style>
+ #myRect {
+ animation-duration: 0.1s;
+ animation-name: fade;
+ animation-fill-mode: forwards;
+ }
+
+ @keyframes fade {
+ 0% { fill-opacity: 0 }
+ 100% { fill-opacity: 1 }
+ }
+ </style>
+ </defs>
+ <rect width="100%" height="100%" fill="red"/>
+ <rect id="myRect" width="100%" height="100%" fill="lime" fill-opacity="0"/>
+</svg>
--- a/image/test/mochitest/mochitest.ini
+++ b/image/test/mochitest/mochitest.ini
@@ -57,16 +57,17 @@ support-files =
iframe.html
imgutils.js
invalid.jpg
keep.gif
keep.png
lime100x100.svg
lime-anim-100x100.svg
lime-anim-100x100-2.svg
+ lime-css-anim-100x100.svg
opaque.bmp
purple.gif
red.gif
red.png
ref-iframe.html
restore-previous.gif
restore-previous.png
rillybad.jpg
--- a/image/test/mochitest/test_animSVGImage.html
+++ b/image/test/mochitest/test_animSVGImage.html
@@ -28,17 +28,21 @@ SimpleTest.waitForExplicitFinish();
const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
const gImg = document.getElementsByTagName("img")[0];
var gMyDecoderObserver; // value will be set in main()
var gReferenceSnapshot; // value will be set in takeReferenceSnapshot()
var gPollCounter = 0;
var gIsTestFinished = false;
-
+var gSVGImages = [
+ "lime-anim-100x100.svg", // SMIL animation
+ "lime-css-anim-100x100.svg" // CSS animation
+]
+var gSVGCurrentImage = 0;
function takeReferenceSnapshot() {
// Take a snapshot of the initial (essentially blank) page
let blankSnapshot = snapshotWindow(window, false);
// Show reference div, & take a snapshot
let referenceDiv = document.getElementById("referenceDiv");
referenceDiv.style.display = "block";
@@ -48,25 +52,37 @@ function takeReferenceSnapshot() {
// Re-hide reference div, and take another snapshot to be sure it's gone
referenceDiv.style.display = "none";
let blankSnapshot2 = snapshotWindow(window, false);
ok(compareSnapshots(blankSnapshot, blankSnapshot2, true)[0],
"reference div should disappear when it becomes display:none");
}
+function loadNextImageAndPoll()
+{
+ setTimeout(myPoll, 1);
+ // kick off image-loading! myPoll handles the rest.
+ gImg.setAttribute("src", gSVGImages[gSVGCurrentImage]);
+}
+
function myPoll() {
gPollCounter++;
ok(true, "myPoll called");
let currentSnapshot = snapshotWindow(window, false);
if (compareSnapshots(currentSnapshot, gReferenceSnapshot, true)[0]) {
// SUCCESS!
ok(true, "Animated image looks correct, " +
"at call #" + gPollCounter + " to myPoll");
- cleanUpAndFinish();
+
+ if (++gSVGCurrentImage > gSVGImages.length) {
+ cleanUpAndFinish();
+ } else {
+ loadNextImageAndPoll();
+ }
}
else
setTimeout(myPoll, 1);
}
function failTest() {
ok(false, "timing out after " + FAILURE_TIMEOUT + "ms. " +
"Animated image still doesn't look correct, " +
@@ -86,20 +102,17 @@ function cleanUpAndFinish() {
function main() {
takeReferenceSnapshot();
// We want to test the cold loading behavior, so clear cache in case an
// earlier test got our image in there already.
clearAllImageCaches();
- setTimeout(myPoll, 1);
-
- // kick off image-loading! myPoll handles the rest.
- gImg.setAttribute("src", "lime-anim-100x100.svg");
+ loadNextImageAndPoll();
// In case something goes wrong, fail earlier than mochitest timeout,
// and with more information.
setTimeout(failTest, FAILURE_TIMEOUT);
}
window.onload = main;