forked from mirrors/gecko-dev
Bug 1507600 [wpt PR 14080] - Improve robustness of wpt animation interpolation tests., a=testonly
Automatic update from web-platform-testsImprove robustness of wpt animation interpolation tests. This patch fixes the problem where subtle changes to numerical values in matrix interpolation cause mismatches in the expected results. To address the issue: * Styles are checked to see if they are of the form matrix(...) or matrix3d(...). * If the style is a matrix, then arguments are rounded and the style is reconstructed. Bug: 797472 Change-Id: I44d6e0ed13e24dc2ecfeeacbcd4809d6dcdb6465 Reviewed-on: https://chromium-review.googlesource.com/c/1337640 Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Kevin Ellis <kevers@chromium.org> Cr-Commit-Position: refs/heads/master@{#608466} -- wpt-commits: 794b7ee9292f09802cd41e41a04be420b1d7bec3 wpt-pr: 14080
This commit is contained in:
parent
51bd6682ca
commit
1681560a62
1 changed files with 25 additions and 1 deletions
|
|
@ -11,6 +11,28 @@ function test_interpolation(settings, expectations, name) {
|
|||
return 'cubic-bezier(0, ' + y + ', 1, ' + y + ')';
|
||||
}
|
||||
|
||||
function RoundMatrix(style) {
|
||||
var matrixMatch = style.match(/^(matrix(3d)?)\(.+\)$/);
|
||||
if (!!matrixMatch) {
|
||||
var matrixType = matrixMatch[1];
|
||||
var matrixArgs = style.substr(matrixType.length);
|
||||
var extractmatrix = function(matrixStr) {
|
||||
var list = [];
|
||||
var regex = /[+\-]?[0-9]+[.]?[0-9]*(e[+/-][0-9]+)?/g;
|
||||
var match = undefined;
|
||||
do {
|
||||
match = regex.exec(matrixStr);
|
||||
if (match) {
|
||||
list.push(parseFloat(parseFloat(match[0]).toFixed(6)));
|
||||
}
|
||||
} while (match);
|
||||
return list;
|
||||
}
|
||||
return matrixType + '(' + extractmatrix(matrixArgs).join(', ') + ')';
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
test(function(){
|
||||
assert_true(CSS.supports(settings.property, settings.from), 'Value "' + settings.from + '" is supported by ' + settings.property);
|
||||
assert_true(CSS.supports(settings.property, settings.to), 'Value "' + settings.to + '" is supported by ' + settings.property);
|
||||
|
|
@ -49,7 +71,9 @@ function test_interpolation(settings, expectations, name) {
|
|||
document.body.appendChild(reference);
|
||||
reference.style = '';
|
||||
|
||||
assert_equals(getComputedStyle(target)[settings.property], getComputedStyle(reference)[settings.property]);
|
||||
var observed = RoundMatrix(getComputedStyle(target)[settings.property]);
|
||||
var expected = RoundMatrix(getComputedStyle(reference)[settings.property]);
|
||||
assert_equals(observed, expected);
|
||||
}, message_prefix + 'Animation between "' + settings.from + '" and "' + settings.to + '" at progress ' + progress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue