Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / implementation-api-args.html
blob0097215d4cbea07df95f18d646680614e849f19e
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-domimplementation">
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Checks that the DOMImplementation api arguments are correctly validated")
11 var testDocument, testPrototype, testNamespace, testQualifiedName, testDocType;
12 function validateDocument(document, prototype, namespace, qualifiedName, docType)
14 testDocument = document;
15 testPrototype = prototype;
16 testNamespace = namespace;
17 testQualifiedName = qualifiedName;
18 testDocType = docType;
20 shouldBe('testDocument.__proto__', 'window["' + prototype + '"].prototype');
21 if (!testQualifiedName || testQualifiedName == "") {
22 shouldBeNull('testDocument.documentElement');
23 } else {
24 shouldBeEqualToString('testDocument.documentElement.tagName', '' + qualifiedName);
25 if (namespace)
26 shouldBeEqualToString('testDocument.documentElement.namespaceURI', '' + namespace);
27 else
28 shouldBeNull('testDocument.documentElement.namespaceURI');
31 if (docType)
32 shouldBe('testDocument.doctype', 'testDocType');
33 else
34 shouldBeNull('testDocument.doctype');
37 debug('\nDocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);');
38 shouldThrow('document.implementation.createDocumentType()', '"TypeError: Failed to execute \'createDocumentType\' on \'DOMImplementation\': 3 arguments required, but only 0 present."');
39 shouldThrow('document.implementation.createDocumentType("qualifiedName")', '"TypeError: Failed to execute \'createDocumentType\' on \'DOMImplementation\': 3 arguments required, but only 1 present."');
40 shouldThrow('document.implementation.createDocumentType("qualifiedName", "publicId")', '"TypeError: Failed to execute \'createDocumentType\' on \'DOMImplementation\': 3 arguments required, but only 2 present."');
41 var docType;
42 shouldNotThrow('docType = document.implementation.createDocumentType("qualifiedName", "publicId", "systemId")');
43 shouldBe('docType.__proto__', 'DocumentType.prototype');
44 shouldBeEqualToString('docType.name', 'qualifiedName');
45 shouldBeEqualToString('docType.publicId', 'publicId');
46 shouldBeEqualToString('docType.systemId', 'systemId');
48 debug('\nXMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, DocumentType? doctype);');
49 shouldThrow('document.implementation.createDocument()', '"TypeError: Failed to execute \'createDocument\' on \'DOMImplementation\': 2 arguments required, but only 0 present."');
50 shouldThrow('document.implementation.createDocument("namespace")', '"TypeError: Failed to execute \'createDocument\' on \'DOMImplementation\': 2 arguments required, but only 1 present."');
51 shouldNotThrow('document.implementation.createDocument("namespace", "qualifiedName")');
52 var doc;
53 shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName", null)');
54 validateDocument(doc, 'XMLDocument', 'namespace', 'qualifiedName', null);
55 shouldNotThrow('doc = document.implementation.createDocument(null, "qualifiedName", null)');
56 validateDocument(doc, 'XMLDocument', null, 'qualifiedName', null);
57 shouldNotThrow('doc = document.implementation.createDocument("", null, null)')
58 validateDocument(doc, 'XMLDocument', "", null, null);
59 shouldNotThrow('doc = document.implementation.createDocument("", "", null)')
60 validateDocument(doc, 'XMLDocument', "", "", null);
61 shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName")');
62 validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", null);
63 shouldNotThrow('doc = document.implementation.createDocument("namespace", "qualifiedName", docType)');
64 validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", docType);
66 debug('\nDocument createHTMLDocument(optional DOMString title);');
67 shouldNotThrow('doc = document.implementation.createHTMLDocument()');
68 validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", doc.doctype);
69 shouldNotThrow('doc = document.implementation.createHTMLDocument("title")');
70 validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", doc.doctype);
71 </script>
72 </body>
73 </html>