Bug 1560705: Fix DOMMatrix test to do approximation r=bzbarsky,emilio

This allows lower precision for DOMMatrix when parsing CSS as the CSS spec does not have number precision requirement.

Differential Revision: https://phabricator.services.mozilla.com/D36197

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kagami Sascha Rosylight 2019-06-27 19:48:23 +00:00
Родитель 0fd81f05c0
Коммит f631f135ff
3 изменённых файлов: 19 добавлений и 19 удалений

Просмотреть файл

@ -1,10 +1,3 @@
[DOMMatrix-001.html]
[new DOMMatrix(undefined)]
expected: FAIL
[new DOMMatrix("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")]
expected: FAIL
[new DOMMatrixReadOnly("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")]
expected: FAIL

Просмотреть файл

@ -96,16 +96,19 @@
}, `new ${constr}(sequence) ${sequence.length} elements`);
});
['scale(2) translateX(5px) translateY(5px)',
'scale(2, 2) translateX(5px) translateY(5px)',
'scale(2)translateX(5px)translateY(5px)',
'scale(2) translateX(calc(2 * 2.5px)) translateY(5px)',
'scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)',
].forEach(function(string) {
test(function() {
checkDOMMatrix(new self[constr](string), scaleTranslate2D);
}, `new ${constr}(${format_value(string)})`);
});
{
const epsilon = 0.0000000005;
['scale(2) translateX(5px) translateY(5px)',
'scale(2, 2) translateX(5px) translateY(5px)',
'scale(2)translateX(5px)translateY(5px)',
'scale(2) translateX(calc(2 * 2.5px)) translateY(5px)',
'scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)',
].forEach(function(string) {
test(function() {
checkMatrix(new self[constr](string), scaleTranslate2D, { epsilon });
}, `new ${constr}(${format_value(string)})`);
});
}
['translateX (5px)',
'scale(2 2) translateX(5) translateY(5)',

Просмотреть файл

@ -35,9 +35,13 @@ function matrix2D(dict) {
return matrix;
}
function checkMatrix(actual, expected) {
function checkMatrix(actual, expected, { epsilon = 0 } = {}) {
for (let member in expected) {
assert_equals(actual[member], expected[member], member);
if (typeof expected[member] === "number") {
assert_approx_equals(actual[member], expected[member], epsilon, member);
} else {
assert_equals(actual[member], expected[member], member);
}
}
}