Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / createElementNS-namespace-errors.html
blob842f202f8282e1d3901c098136601a1a4f755c6a
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
4 <script>
5 description("Test that calling createElementNS() throws an error when http://www.w3.org/TR/dom/#dom-document-createelementns says it should.");
7 // Spec: http://www.w3.org/TR/dom/#dom-document-createelementns
9 // Step 5.
10 shouldThrow("document.createElementNS(null, 'foo:bar')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'\') is not valid for the qualified name provided (\'foo:bar\')."');
12 // Step 6.
13 shouldNotThrow("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc')");
14 shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').namespaceURI", '"http://www.w3.org/XML/1998/namespace"');
15 shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').nodeName", '"xml:abc"');
16 shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').prefix", '"xml"');
17 shouldBe("document.createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:abc').localName", '"abc"');
18 shouldThrow("document.createElementNS('http://www.w3.org/not-XML/1998/namespace', 'xml:abc')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'http://www.w3.org/not-XML/1998/namespace\') is not valid for the qualified name provided (\'xml:abc\')."');
20 // Step 7.
21 shouldNotThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns')");
22 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').namespaceURI", '"http://www.w3.org/2000/xmlns/"');
23 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').nodeName", '"xmlns"');
24 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').prefix", 'null');
25 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns').localName", '"xmlns"');
26 shouldThrow("document.createElementNS('http://www.w3.org/2000/not-xmlns/', 'xmlns')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'http://www.w3.org/2000/not-xmlns/\') is not valid for the qualified name provided (\'xmlns\')."');
28 shouldNotThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc', 'http://wwww.example.org')");
29 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').namespaceURI", '"http://www.w3.org/2000/xmlns/"');
30 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').nodeName", '"xmlns:abc"');
31 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').prefix", '"xmlns"');
32 shouldBe("document.createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:abc').localName", '"abc"');
33 shouldThrow("document.createElementNS('http://www.w3.org/2000/not-xmlns/', 'xmlns:abc', 'http://wwww.example.org')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'http://www.w3.org/2000/not-xmlns/\') is not valid for the qualified name provided (\'xmlns:abc\')."');
35 // Step 8.
36 shouldThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'badprefix:xmlns')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'http://www.w3.org/2000/xmlns/\') is not valid for the qualified name provided (\'badprefix:xmlns\')."');
37 shouldThrow("document.createElementNS('http://www.w3.org/2000/xmlns/', 'notxmlns')", '"NamespaceError: Failed to execute \'createElementNS\' on \'Document\': The namespace URI provided (\'http://www.w3.org/2000/xmlns/\') is not valid for the qualified name provided (\'notxmlns\')."');
38 </script>