OLD | NEW |
1 // [Name] SVGFEComponentTransferElement-svgdom-tableValues-prop.js | 1 // [Name] SVGFEComponentTransferElement-svgdom-tableValues-prop.js |
2 // [Expected rendering result] An image with feComponentTransfer filter - and a
series of PASS messages | 2 // [Expected rendering result] An image with feComponentTransfer filter - and a
series of PASS messages |
3 | 3 |
4 // SVGNumberListToString converts a list to a string. | 4 // SVGNumberListToString converts a list to a string. |
5 function SVGNumberListToString(list) { | 5 function SVGNumberListToString(list) { |
6 var result = ""; | 6 var result = ""; |
7 for (var i = 0; i < list.numberOfItems; ++i) { | 7 for (var i = 0; i < list.numberOfItems; ++i) { |
8 // We should multiply and round the value of listItem otherwise the expe
cted value cannot be precisely represented as a floating point | 8 // We should multiply and round the value of listItem otherwise the expe
cted value cannot be precisely represented as a floating point |
9 // number and later the comparison will fail. | 9 // number and later the comparison will fail. |
10 var item = Math.round(list.getItem(i).value * 1000) / 1000; | 10 var item = Math.round(list.getItem(i).value * 1000) / 1000; |
(...skipping 15 matching lines...) Expand all Loading... |
26 feGFunc.setAttribute("tableValues", "0 1 1 0.5"); | 26 feGFunc.setAttribute("tableValues", "0 1 1 0.5"); |
27 | 27 |
28 var feBFunc = createSVGElement("feFuncB"); | 28 var feBFunc = createSVGElement("feFuncB"); |
29 feBFunc.setAttribute("type", "table"); | 29 feBFunc.setAttribute("type", "table"); |
30 feBFunc.setAttribute("tableValues", "0 0 1 0.1"); | 30 feBFunc.setAttribute("tableValues", "0 0 1 0.1"); |
31 | 31 |
32 var feAFunc = createSVGElement("feFuncA"); | 32 var feAFunc = createSVGElement("feFuncA"); |
33 feAFunc.setAttribute("type", "table"); | 33 feAFunc.setAttribute("type", "table"); |
34 feAFunc.setAttribute("tableValues", "0.5 10 1 0.5"); | 34 feAFunc.setAttribute("tableValues", "0.5 10 1 0.5"); |
35 | 35 |
36 var feCompnentTransferElement = createSVGElement("feComponentTransfer"); | 36 var feComponentTransferElement = createSVGElement("feComponentTransfer"); |
37 feCompnentTransferElement.appendChild(feRFunc); | 37 feComponentTransferElement.appendChild(feRFunc); |
38 feCompnentTransferElement.appendChild(feGFunc); | 38 feComponentTransferElement.appendChild(feGFunc); |
39 feCompnentTransferElement.appendChild(feBFunc); | 39 feComponentTransferElement.appendChild(feBFunc); |
40 feCompnentTransferElement.appendChild(feAFunc); | 40 feComponentTransferElement.appendChild(feAFunc); |
41 | 41 |
42 var compTranFilter = createSVGElement("filter"); | 42 var compTranFilter = createSVGElement("filter"); |
43 compTranFilter.setAttribute("id", "compTranFilter"); | 43 compTranFilter.setAttribute("id", "compTranFilter"); |
44 compTranFilter.setAttribute("filterUnits", "objectBoundingBox"); | 44 compTranFilter.setAttribute("filterUnits", "objectBoundingBox"); |
45 compTranFilter.setAttribute("x", "0%"); | 45 compTranFilter.setAttribute("x", "0%"); |
46 compTranFilter.setAttribute("y", "0%"); | 46 compTranFilter.setAttribute("y", "0%"); |
47 compTranFilter.setAttribute("width", "100%"); | 47 compTranFilter.setAttribute("width", "100%"); |
48 compTranFilter.setAttribute("height", "100%"); | 48 compTranFilter.setAttribute("height", "100%"); |
49 compTranFilter.appendChild(feCompnentTransferElement); | 49 compTranFilter.appendChild(feComponentTransferElement); |
50 | 50 |
51 var defsElement = createSVGElement("defs"); | 51 var defsElement = createSVGElement("defs"); |
52 defsElement.appendChild(compTranFilter); | 52 defsElement.appendChild(compTranFilter); |
53 rootSVGElement.appendChild(defsElement); | 53 rootSVGElement.appendChild(defsElement); |
54 | 54 |
55 var imageElement = createSVGElement("image"); | 55 var imageElement = createSVGElement("image"); |
56 imageElement.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/str
uct-image-01.png"); | 56 imageElement.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/str
uct-image-01.png"); |
57 imageElement.setAttribute("width", "400"); | 57 imageElement.setAttribute("width", "400"); |
58 imageElement.setAttribute("height", "200"); | 58 imageElement.setAttribute("height", "200"); |
59 imageElement.setAttribute("preserveAspectRatio", "none"); | 59 imageElement.setAttribute("preserveAspectRatio", "none"); |
(...skipping 25 matching lines...) Expand all Loading... |
85 number4.value = 0.9; | 85 number4.value = 0.9; |
86 feAFunc.tableValues.baseVal.replaceItem(number4, 3); | 86 feAFunc.tableValues.baseVal.replaceItem(number4, 3); |
87 | 87 |
88 shouldBeEqualToString("SVGNumberListToString(feRFunc.tableValues.baseVal)",
"0 1 0.9 0 "); | 88 shouldBeEqualToString("SVGNumberListToString(feRFunc.tableValues.baseVal)",
"0 1 0.9 0 "); |
89 shouldBeEqualToString("SVGNumberListToString(feGFunc.tableValues.baseVal)",
"0 1 1 0.6 "); | 89 shouldBeEqualToString("SVGNumberListToString(feGFunc.tableValues.baseVal)",
"0 1 1 0.6 "); |
90 shouldBeEqualToString("SVGNumberListToString(feBFunc.tableValues.baseVal)",
"0 0 1 0.2 "); | 90 shouldBeEqualToString("SVGNumberListToString(feBFunc.tableValues.baseVal)",
"0 0 1 0.2 "); |
91 shouldBeEqualToString("SVGNumberListToString(feAFunc.tableValues.baseVal)",
"0.5 10 1 0.9 "); | 91 shouldBeEqualToString("SVGNumberListToString(feAFunc.tableValues.baseVal)",
"0.5 10 1 0.9 "); |
92 } | 92 } |
93 | 93 |
94 var successfullyParsed = true; | 94 var successfullyParsed = true; |
OLD | NEW |