зеркало из https://github.com/mozilla/gecko-dev.git
101 строка
2.9 KiB
HTML
101 строка
2.9 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1167519
|
|
-->
|
|
<head>
|
|
<meta charset=utf-8>
|
|
<title>Test for bug 1167519</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
|
<script src="animation_utils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
|
<style>
|
|
#target {
|
|
height: 100px;
|
|
width: 100px;
|
|
background: green;
|
|
transition: transform 100s linear;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="target"></div>
|
|
<script>
|
|
'use strict';
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
|
|
const omtaEnabled =
|
|
SpecialPowers.DOMWindowUtils.layerManagerRemote &&
|
|
SpecialPowers.getBoolPref(OMTAPrefKey);
|
|
|
|
window.addEventListener('load', async function() {
|
|
if (!omtaEnabled) {
|
|
ok(true, 'Skipping the test since OMTA is disabled');
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
const div = document.getElementById('target');
|
|
|
|
// Start first transition
|
|
div.style.transform = 'translateX(300px)';
|
|
const firstTransition = div.getAnimations()[0];
|
|
|
|
// Wait for first transition to start running on the main thread and
|
|
// compositor.
|
|
await firstTransition.ready;
|
|
await waitForPaints();
|
|
|
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
|
|
// Start second transition
|
|
div.style.transform = 'translateX(600px)';
|
|
const secondTransition = div.getAnimations()[0];
|
|
|
|
const originalProperties = SpecialPowers.wrap(
|
|
secondTransition.effect
|
|
).getProperties();
|
|
const previousPropertyValue = originalProperties[0].values[0].value;
|
|
const previousKeyframeValue = secondTransition.effect.getKeyframes()[0]
|
|
.transform;
|
|
|
|
// Tie up main thread for 300ms. In the meantime, the first transition
|
|
// will continue running on the compositor. If we don't update the start
|
|
// point of the second transition, it will appear to jump when it starts.
|
|
const startTime = performance.now();
|
|
while (performance.now() - startTime < 300);
|
|
|
|
// Ensure that our paint process has been done.
|
|
//
|
|
// Note that requestAnimationFrame is not suitable here since on Android
|
|
// there is a case where the paint process has not completed even when the
|
|
// requestAnimationFrame callback is run (and it is during the paint
|
|
// process that we update the transition start point).
|
|
await waitForPaints();
|
|
|
|
const updatedProperties = SpecialPowers.wrap(
|
|
secondTransition.effect
|
|
).getProperties();
|
|
const currentPropertyValue = updatedProperties[0].values[0].value;
|
|
isnot(
|
|
currentPropertyValue,
|
|
previousPropertyValue,
|
|
'From value of transition is updated since the moment when ' +
|
|
'it was generated'
|
|
);
|
|
isnot(
|
|
secondTransition.effect.getKeyframes()[0].transform,
|
|
previousKeyframeValue,
|
|
'Keyframe value of transition is updated since the moment when ' +
|
|
'it was generated'
|
|
);
|
|
SimpleTest.finish();
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|