Bug 1395512 - Make dom/svg/test/test_text_2.html produce useful and non-inverted error messages. r=jfkthame

MozReview-Commit-ID: KJHRBmbbuBq
This commit is contained in:
Jonathan Watt 2017-08-10 12:47:20 +01:00
Родитель 7a7e0c5a76
Коммит f7d98d6559
1 изменённых файлов: 11 добавлений и 8 удалений

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

@ -14,9 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=655877
<p id="display"></p>
<div id="content">
<svg width="400" height="200">
<text x="100" y="100" style="font: 16px sans-serif">
abc אבג 123 דהו defg
</text>
<text x="100" y="100" style="font: 16px sans-serif">abc אבג 123 דהו defg</text>
</svg>
</div>
@ -25,7 +23,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=655877
SimpleTest.waitForExplicitFinish();
function close(x, y, message) {
ok(Math.abs(x - y) < 1e-4, message);
if (Math.abs(x - y) < 1e-4) {
ok(true, message);
} else {
// Use is() so that the difference is actually printed in the error message
is(x, y, message);
}
}
function runTest() {
@ -43,12 +46,12 @@ function runTest() {
for (var i = 0; i < 20; i++) {
sum += text.getSubStringLength(i, 1);
}
close(total, sum, "sum getSubStringLength 1");
close(sum, total, "sum getSubStringLength 1");
// split the text up into three chunks and add them together
close(total, text.getSubStringLength(0, 6) +
text.getSubStringLength(6, 8) +
text.getSubStringLength(14, 6), "sum getSubStringLength 2");
close(text.getSubStringLength(0, 6) +
text.getSubStringLength(6, 8) +
text.getSubStringLength(14, 6), total, "sum getSubStringLength 2");
SimpleTest.finish();
}