<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>DOM Core: createElementNS() (test without getElementsByTagNameNS)</title>
  <script type="text/javascript">

    function test() {
      var test1 = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
      var container = document.getElementById('test');
      var pre = document.getElementById('result');
      while (pre.hasChildNodes()) pre.removeChild(pre.firstChild);
      runTests(pre, test1);
      container.appendChild(test1);
      runTests(pre, test1);
    }

    function runTests(pre, div) {
      assert(pre, div, "div", "[object HTMLDivElement]");
      assert(pre, div, "div.tagName", "div");
      assert(pre, div, "div.nodeName", "div");
      assert(pre, div, "div.prefix", null);
      assert(pre, div, "div.localName", "div");
      assert(pre, div, "div.namespaceURI", "http://www.w3.org/1999/xhtml");
      assert(pre, div, "div.nodeValue", null);
    }

    function assert(pre, div, value, answer) {
      result = eval(value);
      var span = document.createElementNS('http://www.w3.org/1999/xhtml', 'span');
      span.appendChild(document.createTextNode(value + ' should equal "' + answer + '", actually equals "' + result + '"'));
      span.className = result == answer ? 'pass' : 'fail';
      pre.appendChild(span);
    }

  </script>
  <style type="text/css">
   pre * { display: block; }
   .fail { background: maroon; color: yellow; }
   .pass { color: green; }
  </style>
 </head>
 <body onload="test()">
  <div id="test"/>
  <pre id="result">Test failed. Script did not execute.</pre>
 </body>
</html>
