extra.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Contains extra test cases for parts of DOM Level 2 that aren't covered by the standard W3C test cases. */
  2. var core = require("../../lib/jsdom/level2/core").dom.level2.core;
  3. exports['create an empty document'] = function (test) {
  4. var dom = new core.DOMImplementation();
  5. var document = dom.createDocument(null, null, null);
  6. test.equal(document.childNodes.length, 0, "document should not contain any nodes");
  7. test.done();
  8. }
  9. exports['create a document with namespace URI, but not qualified Name'] = function (test) {
  10. var dom = new core.DOMImplementation();
  11. test.throws(function () { dom.createDocument("http://example.org/motorcycle", null, null); },
  12. core.DOMException), 'should throw a DOMException';
  13. test.done();
  14. }
  15. exports['doctype ownerDocument'] = function (test) {
  16. var dom = new core.DOMImplementation();
  17. var doctype = dom.createDocumentType("bananas");
  18. var document = dom.createDocument(null, null, doctype);
  19. test.equal(doctype.ownerDocument, document, 'doctype should belong to the document');
  20. test.done();
  21. }
  22. exports['doctype child of ownerDocument'] = function (test) {
  23. var dom = new core.DOMImplementation();
  24. var doctype = dom.createDocumentType("hatstand");
  25. var document = dom.createDocument(null, null, doctype);
  26. test.equal(document.firstChild, doctype, 'doctype should be a child of the document')
  27. test.done();
  28. }