1 <svg xmlns=
"http://www.w3.org/2000/svg">
6 testRunner.dumpAsText();
8 var svgNS =
"http://www.w3.org/2000/svg";
9 var pathElement = document.createElementNS(svgNS, 'path');
12 function result(didPass, string) {
13 var newText = document.createElementNS(svgNS,
"text");
14 newText.setAttribute(
"x",
10);
15 newText.setAttribute(
"y", logOffset);
17 newText.textContent = string;
18 var newTspan = document.createElementNS(svgNS,
"tspan");
20 newTspan.textContent =
"PASS: ";
21 newTspan.style.fill =
"green";
23 newTspan.textContent =
"FAIL: ";
24 newTspan.style.fill =
"red";
26 newText.insertBefore(newTspan, newText.firstChild);
27 document.getElementById('log').appendChild(newText);
30 function expectLength(path, expectedLength, errorTolerance) {
31 pathElement.setAttribute(
"d", path);
35 actualLength = pathElement.getTotalLength();
36 if (Math.abs(actualLength - expectedLength) < errorTolerance)
37 result(true, path +
" = " + actualLength);
39 result(false, path +
" expected: " + expectedLength +
" actual: " + actualLength);
41 result(false, path +
" expected: " + expectedLength +
" got exception: " + e);
48 expectLength('M
0 0 L
100 0 L
100 100 L
0 100 Z',
400,
0.000001);
49 expectLength('M
0 0 l
100 0 l
0 100 l -
100 0 Z',
400,
0.000001);
50 expectLength('M
0 0 t
0 100',
100,
0.1);
51 expectLength('M
0 0 Q
55 50 100 100',
141.4803314,
0.000001);
52 expectLength('M
778.4191616766467 375.19086364081954 C
781.239563 375.1908569 786.8525244750526 346.60170830052556 786.8802395209582 346.87991373394766',
29.86020,
0.0001);
53 expectLength('M
0 0 C
0.00001 0.00001 0.00002 0.00001 0.00003 0',
0.0000344338,
0.000000001);