ABC
ABC
This is a test of the SVGLengthList::insertItemBefore() API.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".



Create three SVGLength objects, with values=50,100,150
PASS newLength1.value is 50
PASS newLength2.value is 100
PASS newLength3.value is 150
PASS newLength1 != newLength2 is true
PASS newLength2 != newLength3 is true
PASS newLength3 != newLength1 is true
PASS newLength1.value == newLength2.value - 50 is true
PASS newLength2.value + 50 == newLength3.value is true

Check initial list state
PASS text1.x.baseVal.numberOfItems is 3
PASS text1.x.baseVal.getItem(0).value is 500
PASS text1.x.baseVal.getItem(1).value is 1000
PASS text1.x.baseVal.getItem(2).value is 1500
PASS text1.x.baseVal.getItem(3) threw exception Error: IndexSizeError: DOM Exception 1.

Insert item 'newLength1' at the end of the list, by using a large index
PASS text1.x.baseVal.insertItemBefore(newLength1, 1000) is newLength1
PASS text1.x.baseVal.numberOfItems is 4
PASS text1.x.baseVal.getItem(0).value is 500
PASS text1.x.baseVal.getItem(1).value is 1000
PASS text1.x.baseVal.getItem(2).value is 1500
PASS text1.x.baseVal.getItem(3).value is 50
PASS text1.x.baseVal.getItem(4) threw exception Error: IndexSizeError: DOM Exception 1.

Storing getItem(0/1/2) in local variables

Insert item 'newLength2' at the front of the list, by using index=0
PASS text1.x.baseVal.insertItemBefore(newLength2, 0) is newLength2
PASS text1.x.baseVal.numberOfItems is 5
PASS text1.x.baseVal.getItem(0).value is 100
PASS text1.x.baseVal.getItem(1).value is 500
PASS text1.x.baseVal.getItem(2).value is 1000
PASS text1.x.baseVal.getItem(3).value is 1500
PASS text1.x.baseVal.getItem(4).value is 50
PASS text1.x.baseVal.getItem(5) threw exception Error: IndexSizeError: DOM Exception 1.

Assure that previously saved wrappers still show the old values
PASS item0.value is 500
PASS item1.value is 1000
PASS item2.value is 1500
PASS item3.value is 50

Insert item 'newLength3' at position=2, between '500' and '1000'
PASS text1.x.baseVal.insertItemBefore(newLength3, 2) is newLength3
PASS text1.x.baseVal.numberOfItems is 6
PASS text1.x.baseVal.getItem(0).value is 100
PASS text1.x.baseVal.getItem(1).value is 500
PASS text1.x.baseVal.getItem(2).value is 150
PASS text1.x.baseVal.getItem(3).value is 1000
PASS text1.x.baseVal.getItem(4).value is 1500
PASS text1.x.baseVal.getItem(5).value is 50
PASS text1.x.baseVal.getItem(6) threw exception Error: IndexSizeError: DOM Exception 1.

Insert item 'newLength3' at position=1, between '100' and '500', remove it from the old position=2 afterwards.
PASS text1.x.baseVal.insertItemBefore(newLength3, 1) is newLength3
PASS text1.x.baseVal.numberOfItems is 6
PASS text1.x.baseVal.getItem(0).value is 100
PASS text1.x.baseVal.getItem(1).value is 150
PASS text1.x.baseVal.getItem(2).value is 500
PASS text1.x.baseVal.getItem(3).value is 1000
PASS text1.x.baseVal.getItem(4).value is 1500
PASS text1.x.baseVal.getItem(5).value is 50
PASS text1.x.baseVal.getItem(6) threw exception Error: IndexSizeError: DOM Exception 1.

Insert item 'newLength3' at position=0, before '100', remove it from the old position=5 afterwards.
PASS text1.x.baseVal.insertItemBefore(newLength1, 0) is newLength1
PASS text1.x.baseVal.numberOfItems is 6
PASS text1.x.baseVal.getItem(0).value is 50
PASS text1.x.baseVal.getItem(1).value is 100
PASS text1.x.baseVal.getItem(2).value is 150
PASS text1.x.baseVal.getItem(3).value is 500
PASS text1.x.baseVal.getItem(4).value is 1000
PASS text1.x.baseVal.getItem(5).value is 1500
PASS text1.x.baseVal.getItem(6) threw exception Error: IndexSizeError: DOM Exception 1.

The test passes if you only see 'PASS' messages, and both text elements on top look the same

PASS successfullyParsed is true

TEST COMPLETE

