function close(x, y, 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() { var text = document.querySelector("text");
// there are only 20 addressable characters
is(text.getNumberOfChars(), 20, "getNumberOfChars");
// add the advance of each glyph
sum = 0;
for (var i = 0; i < 20; i++) {
sum += text.getSubStringLength(i, 1);
}
close(sum, total, "sum getSubStringLength 1");
// split the text up into three chunks and add them together
close(text.getSubStringLength(0, 6) +
text.getSubStringLength(6, 8) +
text.getSubStringLength(14, 6), total, "sum getSubStringLength 2");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.