Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / coreDOM-element-attribute-js-null.xhtml
blobc8c47cd87d8f2a2a8bc84fc5a8e4d4ea40b45a7c
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <style type="text/css">
4 .pass { color: green; }
5 .fail { color: red; }
6 </style>
7 <script type="text/javascript" charset="utf-8">
8 function printOut(msg)
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)
20 if (result === "")
21 return "the empty string";
22 else if (result === undefined)
23 return "undefined";
24 else if (result === null)
25 return "null";
26 return "the string '" + result + "'";
29 function nullTestElementAttribute(elementType, element, attr, expected)
31 element[attr] = null;
33 var result;
34 if (element[attr] === expected)
35 result = "TEST SUCCEEDED: The value was " + resultStringifier(expected) + ".";
36 else
37 result = "TEST FAILED: The value should have been " + resultStringifier(expected) + " but was " + resultStringifier(element[attr]) + ".";
39 result += " [tested " + elementType + "." + attr + "]";
40 printOut(result);
43 function runTests()
45 if (window.testRunner)
46 testRunner.dumpAsText();
48 var listing = [
50 type: 'Attr',
51 elementToUse: document.createAttributeNS('http://www.w3.org/1999/xhtml','anAttribute'),
52 attributes: [
53 {name: 'value', expectedNull: 'null'},
54 {name: 'nodeValue', expectedNull: ''},
55 {name: 'textContent', expectedNull: ''}
59 type: 'ProcessingInstruction',
60 elementToUse: document.createProcessingInstruction('target', 'data'),
61 attributes: [
62 {name: 'data', expectedNull: ''}
66 type: 'CharacterData',
67 elementToUse: document.createTextNode('text'),
68 attributes: [
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;
78 for (attr in attrs) {
79 nullTestElementAttribute(type, elementToUse, attrs[attr].name, attrs[attr].expectedNull);
81 printOut('');
85 </script>
86 </head>
88 <body onload="runTests();">
89 <p>This test setting various attributes of a elements to JavaScript null.</p>
90 <div id="console"></div>
91 </body>
92 </html>