зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
0fd81f05c0
Коммит
f631f135ff
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче