1 <svg xmlns=
"http://www.w3.org/2000/svg">
5 if (window.layoutTestController)
6 layoutTestController.dumpAsText();
8 var svgNS =
"http://www.w3.org/2000/svg";
9 var pathElement = document.createElementNS(svgNS, 'path');
10 var errorTolerance =
.1;
13 function result(didPass, string) {
14 var newText = document.createElementNS(svgNS,
"text");
15 newText.setAttribute(
"x",
10);
16 newText.setAttribute(
"y", logOffset);
18 newText.textContent = string;
19 var newTspan = document.createElementNS(svgNS,
"tspan");
21 newTspan.textContent =
"PASS: ";
22 newTspan.style.fill =
"green";
24 newTspan.textContent =
"FAIL: ";
25 newTspan.style.fill =
"red";
27 newText.insertBefore(newTspan, newText.firstChild);
28 document.getElementById('log').appendChild(newText);
31 function expectLength(path, expectedLength) {
32 pathElement.setAttribute(
"d", path);
36 actualLength = pathElement.getTotalLength();
37 if (Math.abs(actualLength - expectedLength) < errorTolerance)
38 result(true, path +
"\" =
" + actualLength);
40 result(false, path + "\
" expected: " + expectedLength +
" actual: " + actualLength);
42 result(false, path +
"\" expected:
" + expectedLength + " got exception:
" + e);
49 expectLength('M 0 0 L 100 0 L 100 100 L 0 100 Z', 400);
50 expectLength('M 0 0 l 100 0 l 0 100 l -100 0 Z', 400);
51 expectLength('M 0 0 t 0 100', 100);
52 expectLength('M 0 0 Q 55 50 100 100', 141.4); // I'm not sure if this is actually right