blob: 2c2e7efe9376ec5b52785d6a9b51b6473c797a8e [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Test that calling createElementNS() throws an error when <a href="http://www.w3.org/TR/dom/#dom-document-createelementns">the DOM spec</a> says it should.');
// Spec: http://www.w3.org/TR/dom/#dom-document-createelementns
// Step 5.
shouldThrow("document.createElementNS(null, 'foo:bar')", '"NamespaceError (DOM Exception 14): The operation is not allowed by Namespaces in XML."');
// Step 6.
shouldNotThrow("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc')");
shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').namespaceURI", '"http://www.w3.org/XML/1998/namespace"');
shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').nodeName", '"xml:abc"');
shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').prefix", '"xml"');
shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').localName", '"abc"');
shouldThrowErrorName("document.createElementNS('http://www.w3.org/not-XML/1998/namespace', 'xml:abc')", 'NamespaceError');
// Step 7.
shouldNotThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns')");
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').namespaceURI", '"http://www.w3.org/2000/xmlns/"');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').nodeName", '"xmlns"');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').prefix", 'null');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').localName", '"xmlns"');
shouldThrowErrorName("document.createElementNS('http://www.w3.org/2000/not-xmlns/', 'xmlns')", 'NamespaceError');
shouldNotThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc')");
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').namespaceURI", '"http://www.w3.org/2000/xmlns/"');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').nodeName", '"xmlns:abc"');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').prefix", '"xmlns"');
shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').localName", '"abc"');
shouldThrowErrorName("document.createElementNS('http://www.w3.org/2000/not-xmlns/', 'xmlns:abc')", 'NamespaceError');
// Step 8.
shouldThrowErrorName("document.createElementNS('http://www.w3.org/2000/xmlns/', 'badprefix:xmlns')", 'NamespaceError');
shouldThrowErrorName("document.createElementNS('http://www.w3.org/2000/xmlns/', 'notxmlns')", 'NamespaceError');
</script>
<script src="../../resources/js-test-post.js"></script>