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

Unified Diff: third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js

Issue 1452543002: Make responsive-test.js use Web Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js
diff --git a/third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js b/third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js
index aacdbb60b1bff99f85951a597f4b465b20ff30af..9cd7881494811f3aeed06411aa51a434381ea946 100644
--- a/third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js
+++ b/third_party/WebKit/LayoutTests/animations/responsive/resources/responsive-test.js
@@ -35,8 +35,6 @@ This test is designed to catch stale interpolation caches.
(function() {
'use strict';
-var sharedStyle = null;
-var animationCount = 0;
var pendingResponsiveTests = [];
function assertResponsive(options) {
@@ -92,33 +90,22 @@ function setState(targets, property, state) {
}
}
-function createAnimationName() {
- return 'anim' + (animationCount++);
+function createKeyframes(property, from, to) {
+ return [
+ {[property]: from},
+ {[property]: to},
+ ];
}
-function createKeyframes(animationName, property, from, to) {
- return `
-@keyframes ${animationName} {
- from { ${property}: ${from}; }
- to { ${property}: ${to}; }
-}`;
-}
-
-function addGlobalStyle(styleText) {
- if (!sharedStyle) {
- sharedStyle = createElement('style', document.documentElement);
- }
- sharedStyle.textContent += styleText;
-}
-
-function startPausedAnimations(targets, animationName, fractions) {
+function startPausedAnimations(targets, keyframes, fractions) {
console.assert(targets.length == fractions.length);
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
var fraction = fractions[i];
- console.assert(fraction >= 0 && fraction <= 1);
- target.style.animation = `${animationName} 1s linear both paused`;
- target.style.animationDelay = `${-fraction}s`;
+ console.assert(fraction >= 0 && fraction < 1);
+ var animation = target.animate(keyframes, 1);
+ animation.currentTime = fraction;
+ animation.pause();
}
}
@@ -128,8 +115,7 @@ function runPendingResponsiveTests() {
var property = options.property;
var from = options.from;
var to = options.to;
- var animationName = createAnimationName();
- addGlobalStyle(createKeyframes(animationName, property, from, to));
+ var keyframes = createKeyframes(property, from, to);
var stateTransitions = createStateTransitions(options.configurations);
stateTransitions.forEach(function(stateTransition) {
@@ -139,7 +125,7 @@ function runPendingResponsiveTests() {
var targets = createTargets(after.expect.length, container);
setState(targets, property, before.state);
- startPausedAnimations(targets, animationName, after.expect.map(function(expectation) { return expectation.at; }));
+ startPausedAnimations(targets, keyframes, after.expect.map(function(expectation) { return expectation.at; }));
stateTransitionTests.push({
applyStateTransition() {
setState(targets, property, after.state);
@@ -158,9 +144,6 @@ function runPendingResponsiveTests() {
});
});
- // Force style recalc to instantiate animations internally.
- getComputedStyle(document.body).color;
-
// Separate style modification from measurement as different phases to avoid a style recalc storm.
for (var stateTransitionTest of stateTransitionTests) {
stateTransitionTest.applyStateTransition();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698