1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=631437
6 <title>Tests the array indexing and .length on SVGXXXList objects
</title>
7 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=631437">Mozilla Bug
631437</a>
12 <svg xmlns=
"http://www.w3.org/2000/svg" id=
"svg">
13 <text id=
"text" x=
"10 20 30" rotate=
"40 50 60">abcde
</text>
14 <path id=
"path" d=
"M0,0 L100,100"/>
15 <polygon id=
"poly" points=
"50,50 70,70 90,50"/>
16 <g id=
"g" transform=
"translate(20 30) rotate(50 60 70) scale(2)"
17 requiredExtensions=
"foo bar baz"/>
19 <script type=
"text/javascript"><![CDATA
[
21 var text
= document
.getElementById("text"),
22 path
= document
.getElementById("path"),
23 poly
= document
.getElementById("poly"),
24 g
= document
.getElementById("g");
26 function CheckList(aListObject
, aExpectedListLength
, aListDescription
) {
27 is(aListObject
.numberOfItems
, aExpectedListLength
, aListDescription
+ ".numberOfItems");
28 is(aListObject
.length
, aExpectedListLength
, aListDescription
+ ".length");
29 for (let i
= 0; i
< aListObject
.length
; i
++) {
30 let item
= aListObject
.getItem(i
);
31 ok(aListObject
[i
] === item
, aListDescription
+ "[" + i
+ "]");
33 is(typeof(aListObject
[aListObject
.length
]), "undefined", aListDescription
+ "[outOfBounds]");
39 listProperty
: "x.baseVal",
40 type
: "SVGLengthList",
41 subtests
: [ { values
: null, length
: 3 },
42 { values
: "40", length
: 1 },
43 { values
: "1em 2em 3em 4em 5em", length
: 5 } ] },
46 listProperty
: "rotate.baseVal",
47 type
: "SVGNumberList",
48 subtests
: [ { values
: null, length
: 3 },
49 { values
: "10", length
: 1 },
50 { values
: "1 2 3 4 5", length
: 5 } ] },
53 listProperty
: "animatedPoints",
55 subtests
: [ { values
: null, length
: 3 },
56 { values
: "100,100", length
: 1 },
57 { values
: "0,0 10,10 20,0 30,10 40,0", length
: 5 } ] },
59 attribute
: "transform",
60 listProperty
: "transform.baseVal",
61 type
: "SVGTransformList",
62 subtests
: [ { values
: null, length
: 3 },
63 { values
: "skewX(45)", length
: 1 },
64 { values
: "translate(1 2) rotate(3) scale(4) skewY(5) skewX(6)",
67 attribute
: "requiredExtensions",
68 listProperty
: "requiredExtensions",
69 type
: "SVGStringList",
70 subtests
: [ { values
: null, length
: 3 },
71 { values
: "foo", length
: 1 },
72 { values
: "foo bar baz qux", length
: 4 } ] },
75 for (let test
of tests
) {
76 let list
= test
.element
;
77 for (let property
of test
.listProperty
.split(".")) {
78 list
= list
[property
];
81 for (let subtest
of test
.subtests
) {
83 test
.element
.setAttribute(test
.attribute
, subtest
.values
);
86 CheckList(list
, subtest
.length
,
87 test
.type
+ ": " + test
.element
.localName
+ "." +