1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 <style type=
"text/css">
4 .pass { color: green
; }
7 <script type=
"text/javascript" charset=
"utf-8">
10 var console = document.getElementById(
"console");
11 var span = document.createElementNS('http://www.w3.org/
1999/xhtml', 'span');
12 // span.innerHTML = msg +
"<br />";
13 span.appendChild(document.createTextNode(msg));
14 span.appendChild(document.createElementNS('http://www.w3.org/
1999/xhtml', 'br'));
15 console.appendChild(span);
18 function resultStringifier(result)
21 return
"the empty string";
22 else if (result === undefined)
24 else if (result === null)
26 return
"the string '" + result +
"'";
29 function nullTestElementAttribute(elementType, element, attr, expected)
34 if (element[attr] === expected)
35 result =
"TEST SUCCEEDED: The value was " + resultStringifier(expected) +
".";
37 result =
"TEST FAILED: The value should have been " + resultStringifier(expected) +
" but was " + resultStringifier(element[attr]) +
".";
39 result +=
" [tested " + elementType +
"." + attr +
"]";
45 if (window.testRunner)
46 testRunner.dumpAsText();
51 elementToUse: document.createAttributeNS('http://www.w3.org/
1999/xhtml','anAttribute'),
53 {name: 'value', expectedNull: 'null'},
54 {name: 'nodeValue', expectedNull: ''},
55 {name: 'textContent', expectedNull: ''}
59 type: 'ProcessingInstruction',
60 elementToUse: document.createProcessingInstruction('target', 'data'),
62 {name: 'data', expectedNull: ''}
66 type: 'CharacterData',
67 elementToUse: document.createTextNode('text'),
69 {name: 'data', expectedNull: ''}
74 for (element in listing) {
75 var type = listing[element].type;
76 var elementToUse = listing[element].elementToUse;
77 var attrs = listing[element].attributes;
79 nullTestElementAttribute(type, elementToUse, attrs[attr].name, attrs[attr].expectedNull);
88 <body onload=
"runTests();">
89 <p>This test setting various attributes of a elements to JavaScript null.
</p>
90 <div id=
"console"></div>