зеркало из https://github.com/mozilla/gecko-dev.git
Bug 649440 test: Convert randomorange reftest img-anim-1.html into a chrome mochitest that polls for onStopFrame notifications until animation completes. r=joe
--HG-- rename : layout/reftests/svg/as-image/lime-anim-100x100.svg => modules/libpr0n/test/mochitest/lime-anim-100x100.svg
This commit is contained in:
Родитель
b166f2a101
Коммит
6fcad3e7db
|
@ -1,19 +0,0 @@
|
|||
<html class="reftest-wait">
|
||||
<head>
|
||||
<script>
|
||||
function snapshot() {
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
function snapshotAfterOnePaint() {
|
||||
window.addEventListener("MozBeforePaint", snapshot, false);
|
||||
window.mozRequestAnimationFrame();
|
||||
}
|
||||
/* After the first paint completes (MozReftestInvalidate), then at that
|
||||
point we wait for *one* more paint, and *then* we take our reftest snapshot. */
|
||||
window.addEventListener("MozReftestInvalidate", snapshotAfterOnePaint, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="lime-anim-100x100.svg">
|
||||
</body>
|
||||
</html>
|
|
@ -56,7 +56,6 @@ fails-if(d2d) == img-simple-7.html img-simple-7-ref.html # bug 633072
|
|||
fails-if(Android) asserts(72) == img-and-image-1.html img-and-image-1-ref.svg
|
||||
|
||||
# More complex <img> tests
|
||||
random-if(gtk2Widget) == img-anim-1.html lime100x100-ref.html # bug 612214
|
||||
== img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html
|
||||
== img-dyn-1.html img-dyn-1-ref.html
|
||||
== img-foreignObject-1.html lime100x100-ref.html
|
||||
|
|
|
@ -74,11 +74,19 @@ _TEST_FILES = imgutils.js \
|
|||
test_bug553982.html \
|
||||
test_bug601470.html \
|
||||
test_bug614392.html \
|
||||
$(NULL)
|
||||
$(NULL)
|
||||
|
||||
# Tests disabled due to intermittent orange
|
||||
# test_bug435296.html disabled - See bug 578591
|
||||
# test_bug478398.html disabled - See bug 579139
|
||||
|
||||
_CHROME_FILES = imgutils.js \
|
||||
lime-anim-100x100.svg \
|
||||
test_animSVGImage.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
||||
|
||||
libs:: $(_CHROME_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// Helper file for shared image functionality
|
||||
//
|
||||
// Note that this is use by tests elsewhere in the source tree. When in doubt,
|
||||
|
@ -119,3 +120,16 @@ function getImagePref(pref)
|
|||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
// JS implementation of imgIDecoderObserver with stubs for all of its methods.
|
||||
function ImageDecoderObserverStub()
|
||||
{
|
||||
this.onStartRequest = function onStartRequest(aRequest) {}
|
||||
this.onStartDecode = function onStartDecode(aRequest) {}
|
||||
this.onStartContainer = function onStartContainer(aRequest, aContainer) {}
|
||||
this.onStartFrame = function onStartFrame(aRequest, aFrame) {}
|
||||
this.onStopFrame = function onStopFrame(aRequest, aFrame) {}
|
||||
this.onStopContainer = function onStopContainer(aRequest, aContainer) {}
|
||||
this.onStopDecode = function onStopDecode(aRequest, status, statusArg) {}
|
||||
this.onStopRequest = function onStopRequest(aRequest, aIsLastPart) {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
|
||||
width="100" height="100">
|
||||
<rect width="100%" height="100%" fill="red"/>
|
||||
<rect x="-600" width="100%" height="100%" fill="lime">
|
||||
<animate attributeName="x" by="600" dur="0.1" fill="freeze"/>
|
||||
</rect>
|
||||
</svg>
|
После Ширина: | Высота: | Размер: 273 B |
|
@ -0,0 +1,113 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=610419
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 610419</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<script type="application/javascript" src="imgutils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=610419">Mozilla Bug 610419</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<div id="referenceDiv" style="height: 100px; width: 100px;
|
||||
display: none; background: lime"></div>
|
||||
<img>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.8">
|
||||
/** Test for Bug 610419**/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const gImg = document.getElementsByTagName("img")[0];
|
||||
|
||||
var gMyDecoderObserver; // value will be set in main()
|
||||
var gReferenceSnapshot; // value will be set in takeReferenceSnapshot()
|
||||
var gOnStopFrameCounter = 0;
|
||||
var gIsTestFinished = false;
|
||||
|
||||
|
||||
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";
|
||||
gReferenceSnapshot = snapshotWindow(window, false);
|
||||
ok(compareSnapshots(blankSnapshot, gReferenceSnapshot, false)[0],
|
||||
"reference snapshot shouldn't match blank page snapshot");
|
||||
|
||||
// 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 myOnStopFrame(aRequest, aFrame) {
|
||||
gOnStopFrameCounter++;
|
||||
let currentSnapshot = snapshotWindow(window, false);
|
||||
if (compareSnapshots(currentSnapshot, gReferenceSnapshot, true)[0]) {
|
||||
// SUCCESS!
|
||||
ok(true, "Animated image looks correct, " +
|
||||
"at call #" + gOnStopFrameCounter + " to onStopFrame");
|
||||
cleanUpAndFinish();
|
||||
}
|
||||
}
|
||||
|
||||
function failTest() {
|
||||
ok(false, "timing out after " + FAILURE_TIMEOUT + "ms. " +
|
||||
"Animated image still doesn't look correct, " +
|
||||
"after call #" + gOnStopFrameCounter + " to onStopFrame");
|
||||
cleanUpAndFinish();
|
||||
}
|
||||
|
||||
function cleanUpAndFinish() {
|
||||
// On the off chance that failTest and myOnStopFrame are triggered
|
||||
// back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
|
||||
if (gIsTestFinished) {
|
||||
return;
|
||||
}
|
||||
let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
|
||||
imgLoadingContent.removeObserver(gMyDecoderObserver);
|
||||
SimpleTest.finish();
|
||||
gIsTestFinished = true;
|
||||
}
|
||||
|
||||
function main() {
|
||||
takeReferenceSnapshot();
|
||||
|
||||
// Create, customize & attach decoder observer
|
||||
gMyDecoderObserver = new ImageDecoderObserverStub();
|
||||
gMyDecoderObserver.onStopFrame = myOnStopFrame;
|
||||
let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
|
||||
imgLoadingContent.addObserver(gMyDecoderObserver);
|
||||
|
||||
// We want to test the cold loading behavior, so clear cache in case an
|
||||
// earlier test got our image in there already.
|
||||
clearImageCache();
|
||||
|
||||
// kick off image-loading! myOnStopFrame handles the rest.
|
||||
gImg.setAttribute("src", "lime-anim-100x100.svg");
|
||||
|
||||
// In case something goes wrong, fail earlier than mochitest timeout,
|
||||
// and with more information.
|
||||
setTimeout(failTest, FAILURE_TIMEOUT);
|
||||
}
|
||||
|
||||
window.onload = main;
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче