þÿ<?xml version="1.0" encoding="UTF-16" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"[<!ENTITY abc 'def'><!NOTATION someNotationName SYSTEM 'someExternalOrPublicID'>]> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XML Support Test</title> <style type="text/css"> table, tr, th, td { border: 2px solid black; border-collapse: collapse; } th, td { padding: 6px; } .condition_false {background-color:red;} .condition_true {background-color:green;} </style> <script type="text/javascript"><![CDATA[ var results; var NS_XHTML = 'http://www.w3.org/1999/xhtml'; var d = document; function $ (id) { return d.getElementById(id); } function create (elem) { return d.createElementNS(NS_XHTML, elem); } function addResultRow () { var tr, td, txt; tr = create('tr'); var args = Array.prototype.slice.call(arguments); var result = arguments[1] === arguments[2]; if (args.length === 4) { args.splice(-1, 0, result); } else { args.push(result); } for (var i=0; i < args.length; i++) { td = create('td'); txt = args[i]; if (i === 3) { td.className = 'condition_'+txt; // Might also change if 4 arguments (see above), so that can color differently for caveated tests } td.appendChild(d.createTextNode(txt)); tr.appendChild(td); } results.appendChild(tr); } function addResultRows () { for (var i=0; i < arguments.length; i++) { var arg = arguments[i]; try { addResultRow.apply(null, arg); } catch (e) { alert('a') addResultRow(arg[0], 'Failed', arg[2], arg[3]); } } } function startTests () { addResultRows ( ['xmlEncoding', document.xmlEncoding, 'UTF-16', 'Firefox 3.0 uses the file encoding (and supplies info on endianness), not the XML declaration; Firefox 3.1b3 removes the endianness, but still consults encoding of file, not XML Declaration'], ['xmlStandalone', document.xmlStandalone, false, 'Should also test in a document with xmlStandalone="yes" too'], ['xmlVersion', document.xmlVersion, '1.0', 'Should also test in an XML document listed as version 1.1; Firefox does not support and gives an error, while Webkit allows the declaration but only gives an error when an XML1.1-only name is used'], ['doctype.name', document.doctype.name, 'html'], ['doctype.entities.item(0)', document.doctype && document.doctype.entities && document.doctype.entities.item && document.doctype.entities.item(0) ? document.doctype.entities.item(0).nodeName : 'null', 'abc', 'Opera allows access here, but includes the 5 predefined entities, though the spec states they should only be "general entities, both external and internal, declared in the DTD"'], // Fix: test for properties ['doctype.notations.item(0)', document.doctype && document.doctype.notations && document.doctype.notations.item && document.doctype.notations.item(0) ? document.doctype.notations.item(0).nodeName : 'null', 'someNotationName'], // Fix: test for properties ['doctype.publicId', document.doctype ? document.doctype.publicId : null, '-//W3C//DTD XHTML 1.1//EN'], ['doctype.systemId', document.doctype ? document.doctype.systemId : null, 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'], ['doctype.internalSubset', document.doctype.internalSubset, "<!ENTITY abc 'def'><!NOTATION someNotationName SYSTEM 'someExternalOrPublicID'>"], ['documentElement.nodeName', document.documentElement ? document.documentElement.nodeName : null, 'html'], ['documentURI (non-empty string)', document.documentURI, typeof document.documentURI === 'string' && document.documentURI !== '' ? document.documentURI : null] // Safe to guess in this way? ); try { // Needs to be caught in Firefox 3.0 addResultRows(['domConfig', document.domConfig, '']); } catch (e) { addResultRows(['domConfig', '(FAILED VALUE RETRIEVAL)', '']); } addResultRows( [] ); // Other tests? // 1) Unicode non-characters giving error } window.addEventListener('load', function () { var table = create('table'); table.setAttribute('summary', 'Displays results of a test for XML DOM support.'); var caption = create('caption'); caption.appendChild(d.createTextNode('XML DOM Support Test')); var tr = create('tr'); var th = create('th'); th.appendChild(d.createTextNode('Document property')); var th2 = create('th'); th2.appendChild(d.createTextNode('Reported value')); var th3 = create('th'); th3.appendChild(d.createTextNode('Expected value')); var th4 = create('th'); th4.appendChild(d.createTextNode('Passes test?')); var th5 = create('th'); th5.appendChild(d.createTextNode('Caveats?')); table.appendChild(caption); tr.appendChild(th); tr.appendChild(th); tr.appendChild(th2); tr.appendChild(th3); tr.appendChild(th4); tr.appendChild(th5); table.appendChild(tr); table.setAttribute('id', 'results'); $('contents').appendChild(table); results = document.getElementById('results'); startTests(); }, false); ]]></script></head> <body> <div id="contents" /> </body> </html>