<!doctypehtml>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/WindowSnapshot.js"></script> <!-- scrolling=no is just paranoia to ensure that we don't get invalidations due to scrollbars
-->
<iframe scrolling="no" id="iframe"></iframe> <!-- this contains the kTests array -->
<script src="animated_image_test_list.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
/*
* This test duplicates image/test/browser/browser_animated_css_image.js, so keep them in sync.
* This is because we need a browser-chrome test in order to test invalidation (the getSnapshot method there
* uses the same path as painting to the screen, whereas here we are doing a
* separate paint to a surface), but browser-chrome isn't run on android, so test_animated_css_image.html
* gets us android coverage.
*/
// We hit an optimized path in WebRender that doesn't cause a repaint on the
// main thread:
//
// https://searchfox.org/mozilla-central/rev/b7f3977978922d44c7d92ae01c0d4cc2baca7bc2/layout/style/ImageLoader.cpp#553
//
// So our assertions and polling need to be a bit weaker on WR.
const kUsingWebRender = SpecialPowers.DOMWindowUtils.layerManagerType.startsWith("WebRender");
let iframe = document.getElementById("iframe");
let blankSnapshot;
// This ensures the MozAfterPaint events come through as expected.
await SimpleTest.promiseFocus(iframe.contentWindow);
let initial = await snapshotWindow(iframe.contentWindow);
let repaintedElement = getExpectedRepaintedElement(iframe.contentDocument);
if (!kUsingWebRender) {
// Ensure the painted state is clear before we start polling.
SpecialPowers.DOMWindowUtils.checkAndClearPaintedState(repaintedElement);
}
let foundDifferent = false;
let foundInitialAgain = false;
for (let i = 0; i < kNumRetries; ++i) {
let current = await snapshotWindow(iframe.contentWindow);
let [equal, /* s1 */, s2 /* , differentPixels, maxDiff */ ] = compareSnapshots(initial, current, kExpectEqual);
if (!foundDifferent && !equal) {
ok(true, `Found different image after ${i} retries`);
ok(kUsingWebRender || SpecialPowers.DOMWindowUtils.checkAndClearPaintedState(repaintedElement), "Should've repainted the expected element");
info(s2);
foundDifferent = true;
}
// Ensure that we go back to the initial state (animated1.gif) is an
// infinite gif.
if (foundDifferent && equal) {
ok(true, `Found same image again after ${i} retries`);
ok(kUsingWebRender || SpecialPowers.DOMWindowUtils.checkAndClearPaintedState(repaintedElement), "Should've repainted the expected element");
foundInitialAgain = true;
break;
}
ok(foundDifferent && foundInitialAgain, `Should've found a different snapshot and then an equal one, after ${kNumRetries} retries`);
}
onload = async function() {
// First snapshot the blank window.
blankSnapshot = await snapshotWindow(iframe.contentWindow);
// kTests is defined in the imported animated_image_test_list.js so it can
// be shared between tests.
// eslint-disable-next-line no-undef
for (let { html, element } of kTests)
await assertAnimates(html, element);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.