2 <script src=
"../../resources/js-test.js"></script>
5 description("Test that calling setAttributeNS() throws an error when http://www.w3.org/TR/dom/#dom-element-setattributens says it should.");
7 window
.elem
= document
.createElement('test');
9 // Spec: http://www.w3.org/TR/dom/#dom-element-setattributens
12 shouldThrow("elem.setAttributeNS(null, 'foo:bar', 'baz')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'\' is an invalid namespace for attributes."');
15 shouldNotThrow("elem.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:abc', 'foo')");
16 shouldThrow("elem.setAttributeNS('http://www.w3.org/not-XML/1998/namespace', 'xml:abc', 'foo')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'http://www.w3.org/not-XML/1998/namespace\' is an invalid namespace for attributes."');
19 shouldNotThrow("elem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://wwww.example.org')");
20 shouldThrow("elem.setAttributeNS('http://www.w3.org/2000/not-xmlns/', 'xmlns', 'http://wwww.example.org')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'http://www.w3.org/2000/not-xmlns/\' is an invalid namespace for attributes."');
21 shouldNotThrow("elem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc', 'http://wwww.example.org')");
22 shouldThrow("elem.setAttributeNS('http://www.w3.org/2000/not-xmlns/', 'xmlns:abc', 'http://wwww.example.org')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'http://www.w3.org/2000/not-xmlns/\' is an invalid namespace for attributes."');
25 shouldThrow("elem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'badprefix:xmlns', 'http://wwww.example.org')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'http://www.w3.org/2000/xmlns/\' is an invalid namespace for attributes."');
26 shouldThrow("elem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'notxmlns', 'http://wwww.example.org')", '"NamespaceError: Failed to execute \'setAttributeNS\' on \'Element\': \'http://www.w3.org/2000/xmlns/\' is an invalid namespace for attributes."');