1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<html>
<head>
<script>
function debug(str) {
pre = document.getElementById('console');
txt = document.createTextNode(str)
pre.appendChild(txt)
}
function runTests() {
if (window.testRunner)
testRunner.dumpAsText();
var uri = 'http://www.example.org';
// Both null namespaceURI and qname
try {
var doc = document.implementation.createDocument(null, null, null)
if (doc.documentElement) {
debug('FAILURE: Document created should not have a document element')
return;
}
} catch (e) {
debug('FAILURE: Got exception ' + e.message + ' when creating document with null namespaceURI and qualifiedName')
return;
}
// Both empty namespaceURI and qname
try {
var doc = document.implementation.createDocument('', '', null)
if (doc.documentElement) {
debug('FAILURE: Document created should not have a document element')
return;
}
} catch (e) {
debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI and qualifiedName')
return;
}
// Null namespaceURI with qname
try {
var doc = document.implementation.createDocument(null, 'test', null)
if (!doc.documentElement) {
debug('FAILURE: Document created should have a document element')
return;
}
} catch (e) {
debug('FAILURE: Got exception ' + e.message + ' when creating document with null namespaceURI')
return;
}
// Empty namespaceURI with qname
try {
var doc = document.implementation.createDocument('', 'test', null)
if (!doc.documentElement) {
debug('FAILURE: Document created should have a document element')
return;
}
} catch (e) {
debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI')
return;
}
// namespaceURI with empty qname
try {
var doc = document.implementation.createDocument(uri, '', null)
if (doc.documentElement) {
debug('FAILURE: Document created should not have a document element')
return;
}
} catch (e) {
debug('FAILURE: Got exception ' + e.message + ' when creating document with empty namespaceURI')
return;
}
debug('SUCCESS!')
}
</script>
</head>
<body onload="runTests();">
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.
<pre id="console">
</pre>
</body>
</html>
|