blob: 725a27fbe8cc52055b79de1b80db13e117e8d2d9 [file] [log] [blame]
This tests verifies that namedItem and named getter returns the first matched item for all but all, options, and form controls collections.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.all instanceof HTMLAllCollection is true
FAIL document.all instanceof HTMLCollection should be true. Was false.
PASS initialLength = document.all.length; elements = [insertElementWithId('b', 'foo'), insertElementWithId('q', 'foo')];
document.all.length is initialLength + 2;
PASS document.all['foo'].length is 2
PASS document.all['foo'][0] is elements[0]
PASS document.all['foo'][1] is elements[1]
PASS elements[0].parentNode.removeChild(elements[0]); document.all['foo'] is elements[1]
PASS document.all['no-such-element'] is undefined.
PASS form.elements instanceof HTMLFormControlsCollection is true
PASS form.elements instanceof HTMLCollection is true
PASS form.elements.length is 0
PASS elements = [createElementWithId('input', 'foo'), createElementWithId('input', 'foo')];
form.appendChild(elements[0]); form.elements.length is 1
PASS form.elements['foo'] is elements[0]
PASS form.appendChild(elements[1]); form.elements.length is 2
PASS form.elements['foo'].toString() is '[object RadioNodeList]'
PASS form.elements['foo'].length is 2
PASS form.elements['foo'][0] is elements[0]
PASS form.elements['foo'][1] is elements[1]
PASS form.removeChild(elements[0]); form.elements['foo'] is elements[1]
PASS removeTestElements(); form.elements.length is 0
PASS form.elements['no-such-element'] is undefined.
PASS document.images.length is 0
PASS elements[0] = insertElementWithId('img', 'foo'); document.images.length is 1
PASS elements[1] = insertElementWithId('img', 'foo'); document.images.length is 2
PASS document.images['foo'] is elements[0]
PASS removeTestElements(); document.images.length is 0
PASS document.applets.length is 0
PASS elements[0] = insertElementWithId('object', 'foo', {"type":"application/x-java-applet"}); document.applets.length is 1
PASS elements[1] = insertElementWithId('object', 'foo', {"type":"application/x-java-applet"}); document.applets.length is 2
PASS document.applets['foo'] is elements[0]
PASS removeTestElements(); document.applets.length is 0
PASS document.embeds.length is 0
PASS elements[0] = insertElementWithId('embed', 'foo'); document.embeds.length is 1
PASS elements[1] = insertElementWithId('embed', 'foo'); document.embeds.length is 2
PASS document.embeds['foo'] is elements[0]
PASS removeTestElements(); document.embeds.length is 0
PASS document.forms.length is 1
PASS elements[0] = insertElementWithId('form', 'foo'); document.forms.length is 2
PASS elements[1] = insertElementWithId('form', 'foo'); document.forms.length is 3
PASS document.forms['foo'] is elements[0]
PASS removeTestElements(); document.forms.length is 1
PASS document.links.length is 0
PASS elements[0] = insertElementWithId('a', 'foo', {"href":"some url"}); document.links.length is 1
PASS elements[1] = insertElementWithId('a', 'foo', {"href":"some url"}); document.links.length is 2
PASS elements[2] = insertElementWithId('area', 'foo', {"href":"some url"}); document.links.length is 3
PASS document.links['foo'] is elements[0]
PASS removeTestElements(); document.links.length is 0
PASS document.anchors.length is 0
PASS elements[0] = insertElementWithId('a', 'foo', {"name":"some name"}); document.anchors.length is 1
PASS elements[1] = insertElementWithId('a', 'foo', {"name":"some name"}); document.anchors.length is 2
PASS document.anchors['foo'] is elements[0]
PASS removeTestElements(); document.anchors.length is 0
PASS document.scripts.length is 2
PASS elements[0] = insertElementWithId('script', 'foo'); document.scripts.length is 3
PASS elements[1] = insertElementWithId('script', 'foo'); document.scripts.length is 4
PASS document.scripts['foo'] is elements[0]
PASS removeTestElements(); document.scripts.length is 2
PASS successfullyParsed is true