6 pre
= document
.getElementById('console');
7 text
= document
.createTextNode(str
+ '\n');
12 if (window
.testRunner
)
13 testRunner
.dumpAsText();
15 elem
= document
.createElement('test');
16 elem
.setAttribute('attr_name', 'attr_value');
17 write("Add an attribute:");
19 write(" setAttribute(attr_name)");
21 write("The following should be non-empty, true, or non-null.");
23 write(" getAttribute(attr_name) = " + elem
.getAttribute('attr_name'));
24 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
25 write(" getAttributeNode(attr_name) = " + elem
.getAttributeNode('attr_name'));
26 write(" attributes.getNamedItem(attr_name) = " + elem
.attributes
.getNamedItem('attr_name'));
28 write(" getAttributeNS(attr_name) = " + elem
.getAttributeNS(null, 'attr_name'));
29 write(" hasAttributeNS(attr_name) = " + elem
.hasAttributeNS(null, 'attr_name'));
30 write(" getAttributeNodeNS(attr_name) = " + elem
.getAttributeNodeNS(null, 'attr_name'));
31 write(" attributes.getNamedItemNS(attr_name) = " + elem
.attributes
.getNamedItemNS(null, 'attr_name'));
33 write(" getAttribute(ATTR_NAME) = " + elem
.getAttribute('ATTR_NAME'));
34 write(" hasAttribute(ATTR_NAME) = " + elem
.hasAttribute('ATTR_NAME'));
35 write(" getAttributeNode(ATTR_NAME) = " + elem
.getAttributeNode('ATTR_NAME'));
36 write(" attributes.getNamedItem(ATTR_NAME) = " + elem
.attributes
.getNamedItem('ATTR_NAME'));
38 write("The following should be empty, false, or null.");
40 write(" getAttributeNS(ATTR_NAME) = " + elem
.getAttributeNS(null, 'ATTR_NAME'));
41 write(" hasAttributeNS(ATTR_NAME) = " + elem
.hasAttributeNS(null, 'ATTR_NAME'));
42 write(" getAttributeNodeNS(ATTR_NAME) = " + elem
.getAttributeNodeNS(null, 'ATTR_NAME'));
43 write(" attributes.getNamedItemNS(ATTR_NAME) = " + elem
.attributes
.getNamedItemNS(null, 'ATTR_NAME'));
45 write("The following should successfully remove the attribute.");
47 elem
.setAttribute('attr_name', 'attr_value');
48 elem
.removeAttribute('attr_name');
49 write(" setAttribute(attr_name); removeAttribute(attr_name)")
50 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
51 elem
.setAttribute('attr_name', 'attr_value');
52 elem
.removeAttributeNS(null, 'attr_name');
53 write(" setAttribute(attr_name); removeAttributeNS(attr_name)")
54 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
55 elem
.setAttribute('attr_name', 'attr_value');
56 elem
.attributes
.removeNamedItem('attr_name');
57 write(" setAttribute(attr_name); attributes.removeNamedItem(attr_name)")
58 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
59 elem
.setAttribute('attr_name', 'attr_value');
60 elem
.attributes
.removeNamedItemNS(null, 'attr_name');
61 write(" setAttribute(attr_name); attributes.removeNamedItemNS(null, attr_name)")
62 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
64 elem
.setAttribute('attr_name', 'attr_value');
65 elem
.removeAttribute('ATTR_NAME');
66 write(" setAttribute(attr_name); removeAttribute(ATTR_NAME)")
67 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
68 elem
.setAttribute('attr_name', 'attr_value');
69 elem
.attributes
.removeNamedItem('ATTR_NAME');
70 write(" setAttribute(attr_name); attributes.removeNamedItem(ATTR_NAME)")
71 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
73 write("The following should fail to remove the attribute.");
75 elem
.setAttribute('attr_name', 'attr_value');
76 elem
.removeAttributeNS(null, 'ATTR_NAME');
77 write(" setAttribute(attr_name); removeAttributeNS(ATTR_NAME)")
78 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
80 write("The following should fail to remove the attribute with an exception.");
82 elem
.setAttribute('attr_name', 'attr_value');
84 elem
.attributes
.removeNamedItemNS(null, 'ATTR_NAME');
85 write(" attributes.removeNamedItemNS(ATTR_NAME) was expected to raise an exception but did not");
87 write(" attributes.removeNamedItemNS(ATTR_NAME) raised an exception as expected");
89 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
91 write("The following should set a lowercase attribute, so the result should be true.");
93 elem
.setAttributeNS(null, 'attr_name', 'attr_value');
94 write(" setAttributeNS(attr_name)");
95 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
96 elem
.removeAttributeNS(null, 'attr_name');
98 write("The following should set an uppercase attribute, so the result should be false.");
100 elem
.setAttributeNS(null, 'ATTR_NAME', 'attr_value');
101 write(" setAttributeNS(ATTR_NAME)");
102 write(" hasAttribute(attr_name) = " + elem
.hasAttribute('attr_name'));
103 elem
.removeAttributeNS(null, 'ATTR_NAME');
109 <body onload=
"runTests();">
110 <pre id=
"console">This test checks whether attribute names with uppercase work properly in HTML documents.