Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: LayoutTests/fast/dom/implementation-api-args.html

Issue 22875013: Make several DOMImplementation API arguments mandatory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix createDocument() args Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/implementation-api-args.html
diff --git a/LayoutTests/fast/dom/implementation-api-args.html b/LayoutTests/fast/dom/implementation-api-args.html
new file mode 100644
index 0000000000000000000000000000000000000000..5bb21673cd73730639c6c339179c2fd69010d91b
--- /dev/null
+++ b/LayoutTests/fast/dom/implementation-api-args.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-domimplementation">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Checks that the DOMImplementation api arguments are correctly validated")
+
+var testDocument, testPrototype, testNamespace, testQualifiedName, testDocType;
+function validateDocument(document, prototype, namespace, qualifiedName, docType)
+{
+ testDocument = document;
+ testPrototype = prototype;
+ testNamespace = namespace;
+ testQualifiedName = qualifiedName;
+ testDocType = docType;
+
+ shouldBe('testDocument.__proto__', 'window["' + prototype + '"].prototype');
+ if (!testQualifiedName || testQualifiedName == "") {
+ shouldBeNull('testDocument.documentElement');
+ } else {
+ shouldBeEqualToString('testDocument.documentElement.tagName', '' + qualifiedName);
+ if (namespace)
+ shouldBeEqualToString('testDocument.documentElement.namespaceURI', '' + namespace);
+ else
+ shouldBeNull('testDocument.documentElement.namespaceURI');
+ }
+
+ if (docType)
+ shouldBe('testDocument.doctype', 'testDocType');
+ else
+ shouldBeNull('testDocument.doctype');
+}
+
+debug('\nDocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);');
+shouldThrow('document.implementation.createDocumentType()', "'TypeError: Not enough arguments'");
+shouldThrow('document.implementation.createDocumentType("qualifiedName")', "'TypeError: Not enough arguments'");
+shouldThrow('document.implementation.createDocumentType("qualifiedName", "publicId")', "'TypeError: Not enough arguments'");
+var docType;
+shouldNotThrow('docType = document.implementation.createDocumentType("qualifiedName", "publicId", "systemId")');
+shouldBe('docType.__proto__', 'DocumentType.prototype');
+shouldBeEqualToString('docType.name', 'qualifiedName');
+shouldBeEqualToString('docType.publicId', 'publicId');
+shouldBeEqualToString('docType.systemId', 'systemId');
+
+debug('\nXMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, DocumentType? doctype);');
+shouldThrow('document.implementation.createDocument()', "'TypeError: Not enough arguments'");
+shouldThrow('document.implementation.createDocument("namespace")', "'TypeError: Not enough arguments'");
+shouldNotThrow('document.implementation.createDocument("namespace", "qualifiedName")');
+var doc;
+shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName", null)');
+validateDocument(doc, 'XMLDocument', 'namespace', 'qualifiedName', null);
+shouldNotThrow('doc = document.implementation.createDocument(null, "qualifiedName", null)');
+validateDocument(doc, 'XMLDocument', null, 'qualifiedName', null);
+shouldNotThrow('doc = document.implementation.createDocument("", null, null)')
+validateDocument(doc, 'XMLDocument', "", null, null);
+shouldNotThrow('doc = document.implementation.createDocument("", "", null)')
+validateDocument(doc, 'XMLDocument', "", "", null);
+shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName")');
+validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", null);
+shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName", docType)');
+validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", docType);
+
+debug('\nDocument createHTMLDocument(optional DOMString title);');
+shouldNotThrow('doc = document.implementation.createHTMLDocument()');
+validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", doc.doctype);
+shouldNotThrow('doc = document.implementation.createHTMLDocument("title")');
+validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", doc.doctype);
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698