2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / createDocument-empty.html
blobab67b20b2415ff506aa1bae4b89f4805eb7b0db1
1 <html>
2 <head>
3 <script>
4 function debug(str) {
5 pre = document.getElementById('console');
6 txt = document.createTextNode(str)
7 pre.appendChild(txt)
9 function runTests() {
10 if (window.layoutTestController)
11 layoutTestController.dumpAsText();
13 var uri = 'http://www.example.org';
15 // Both null namespaceURI and qname
16 try {
17 var doc = document.implementation.createDocument(null, null, null)
19 if (doc.documentElement) {
20 debug('FAILURE: Document created should not have a document element')
21 return;
23 } catch (e) {
24 debug('FAILURE: Got exception ' + e.message + ' when creating document with null namespaceURI and qualifiedName')
25 return;
28 // Both empty namespaceURI and qname
29 try {
30 var doc = document.implementation.createDocument('', '', null)
32 if (doc.documentElement) {
33 debug('FAILURE: Document created should not have a document element')
34 return;
36 } catch (e) {
37 debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI and qualifiedName')
38 return;
41 // Null namespaceURI with qname
42 try {
43 var doc = document.implementation.createDocument(null, 'test', null)
45 if (!doc.documentElement) {
46 debug('FAILURE: Document created should have a document element')
47 return;
50 } catch (e) {
51 debug('FAILURE: Got exception ' + e.message + ' when creating document with null namespaceURI')
52 return;
55 // Empty namespaceURI with qname
56 try {
57 var doc = document.implementation.createDocument('', 'test', null)
59 if (!doc.documentElement) {
60 debug('FAILURE: Document created should have a document element')
61 return;
64 } catch (e) {
65 debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI')
66 return;
69 // namespaceURI with empty qname
70 try {
71 var doc = document.implementation.createDocument(uri, '', null)
73 if (doc.documentElement) {
74 debug('FAILURE: Document created should not have a document element')
75 return;
78 } catch (e) {
79 debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI')
80 return;
83 debug('SUCCESS!')
86 </script>
87 </head>
88 <body onload="runTests();">
89 This tests that it should be possible to create documents with empty/null qnames and namespaceURIs. If the test is successful, 'SUCCESS' will be displayed below, otherwise 'FAILURE' and a reason will be displayed.
90 <pre id="console">
91 </pre>
92 </body>
93 </html>