Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: third_party/WebKit/LayoutTests/animations/custom-properties/registered-var-to-registered-animating.html

Issue 2809063002: WIP Support var() references in registered custom property keyframes (Closed)
Patch Set: Rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/animations/custom-properties/registered-var-to-registered-animating.html
diff --git a/third_party/WebKit/LayoutTests/animations/custom-properties/registered-var-to-registered-animating.html b/third_party/WebKit/LayoutTests/animations/custom-properties/registered-var-to-registered-animating.html
new file mode 100644
index 0000000000000000000000000000000000000000..a874099cde586553c0fd072dbf231395b49945a5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/animations/custom-properties/registered-var-to-registered-animating.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<style>
+#target {
+ --from: 100;
+}
+</style>
+<div id="target"></div>
+<script>
+for (let name of ['--test', '--from', '--to']) {
+ CSS.registerProperty({
+ name,
+ syntax: '<number>',
+ initialValue: '0',
+ });
+}
+
+test(() => {
+ let animation = target.animate({'--test': ['var(--from)', 'var(--to)']}, 100);
+ let toAnimation = target.animate({'--to': ['200', '300']}, 100);
+
+ toAnimation.currentTime = 25;
+ {
+ animation.currentTime = 25;
+ // lerp(100, lerp(200, 300, 25%), 25%) == 0.75*100 + 0.25*(0.75*200 + 0.25*300) == 131.25
+ assert_equals(getComputedStyle(target).getPropertyValue('--test'), '131.25', 'target at 25%, to at 25%');
+
+ animation.currentTime = 75;
+ // lerp(100, lerp(200, 300, 25%), 75%) == 0.25*100 + 0.75*(0.75*200 + 0.25*300) == 193.75
+ assert_equals(getComputedStyle(target).getPropertyValue('--test'), '193.75', 'target at 75%, to at 25%');
+ }
+
+ toAnimation.currentTime = 75;
+ {
+ animation.currentTime = 25;
+ // lerp(100, lerp(200, 300, 75%), 25%) == 0.75*100 + 0.25*(0.25*200 + 0.75*300) == 143.75
+ assert_equals(getComputedStyle(target).getPropertyValue('--test'), '143.75', 'target at 25%, to at 25%');
+
+ animation.currentTime = 75;
+ // lerp(100, lerp(200, 300, 75%), 75%) == 0.25*100 + 0.75*(0.25*200 + 0.75*300) == 231.25
+ assert_equals(getComputedStyle(target).getPropertyValue('--test'), '231.25', 'target at 75%, to at 25%');
+ }
+}, 'Registered custom property animation keyframes with var() references to animating unregistered custom properties');
+</script>

Powered by Google App Engine
This is Rietveld 408576698