OLD | NEW |
1 description("Tests handling of invalid SVG length units."); | 1 description("Tests handling of invalid SVG length units."); |
2 | 2 |
3 var svgNS = "http://www.w3.org/2000/svg"; | 3 var svgNS = "http://www.w3.org/2000/svg"; |
4 | 4 |
5 var svgRoot = document.createElementNS(svgNS, "svg"); | 5 var svgRoot = document.createElementNS(svgNS, "svg"); |
6 document.documentElement.appendChild(svgRoot); | 6 document.documentElement.appendChild(svgRoot); |
7 | 7 |
8 rect = document.createElementNS(svgNS, "rect"); | 8 rect = document.createElementNS(svgNS, "rect"); |
9 svgRoot.appendChild(rect); | 9 svgRoot.appendChild(rect); |
10 | 10 |
11 function trySettingLength(length, expected) | 11 function trySettingLength(length, expected) |
12 { | 12 { |
13 rect.setAttribute('x', "1234"); | 13 rect.setAttribute('x', "1234"); |
14 shouldBe("rect.setAttribute('x', '" + length + "'); rect.x.baseVal.valueAsSt
ring", expected); | 14 shouldBe("rect.setAttribute('x', '" + length + "'); rect.x.baseVal.valueAsSt
ring", expected); |
15 } | 15 } |
16 | 16 |
17 trySettingLength("", "'0'"); | 17 trySettingLength("", "'0'"); |
18 trySettingLength(" ", "'0'"); | 18 trySettingLength(" ", "'0'"); |
19 trySettingLength("foo", "'0'"); | 19 trySettingLength("foo", "'0'"); |
20 trySettingLength("10foo", "'0'"); | 20 trySettingLength("10foo", "'0'"); |
21 trySettingLength("px", "'0'"); | 21 trySettingLength("px", "'0'"); |
22 trySettingLength("10px ", "'0'"); | 22 trySettingLength("10px ", "'10px'"); |
23 trySettingLength("10% ", "'0'"); | 23 trySettingLength("10% ", "'10%'"); |
24 trySettingLength("10 % ", "'0'"); | 24 trySettingLength("10 % ", "'0'"); |
25 trySettingLength("10 %", "'0'"); | 25 trySettingLength("10 %", "'0'"); |
26 trySettingLength("10 px ", "'0'"); | 26 trySettingLength("10 px ", "'0'"); |
27 trySettingLength("10 px", "'0'"); | 27 trySettingLength("10 px", "'0'"); |
28 trySettingLength("10", "'10'"); | 28 trySettingLength("10", "'10'"); |
29 trySettingLength("10%", "'10%'"); | 29 trySettingLength("10%", "'10%'"); |
30 trySettingLength("10em", "'10em'"); | 30 trySettingLength("10em", "'10em'"); |
31 trySettingLength("10ex", "'10ex'"); | 31 trySettingLength("10ex", "'10ex'"); |
32 trySettingLength("10px", "'10px'"); | 32 trySettingLength("10px", "'10px'"); |
33 trySettingLength("10cm", "'10cm'"); | 33 trySettingLength("10cm", "'10cm'"); |
34 trySettingLength("10mm", "'10mm'"); | 34 trySettingLength("10mm", "'10mm'"); |
35 trySettingLength("10pt", "'10pt'"); | 35 trySettingLength("10pt", "'10pt'"); |
36 trySettingLength("10pc", "'10pc'"); | 36 trySettingLength("10pc", "'10pc'"); |
37 | 37 |
38 document.documentElement.removeChild(svgRoot); | 38 document.documentElement.removeChild(svgRoot); |
39 | 39 |
40 var successfullyParsed = true; | 40 var successfullyParsed = true; |
OLD | NEW |