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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-domi mplementation">
5 <script src="../js/resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Checks that the DOMImplementation api arguments are correctly valid ated")
10
11 var testDocument, testPrototype, testNamespace, testQualifiedName, testDocType;
12 function validateDocument(document, prototype, namespace, qualifiedName, docType )
13 {
14 testDocument = document;
15 testPrototype = prototype;
16 testNamespace = namespace;
17 testQualifiedName = qualifiedName;
18 testDocType = docType;
19
20 shouldBe('testDocument.__proto__', 'window["' + prototype + '"].prototype');
21 if (!testQualifiedName || testQualifiedName == "") {
22 shouldBeNull('testDocument.documentElement');
23 } else {
24 shouldBeEqualToString('testDocument.documentElement.tagName', '' + quali fiedName);
25 if (namespace)
26 shouldBeEqualToString('testDocument.documentElement.namespaceURI', ' ' + namespace);
27 else
28 shouldBeNull('testDocument.documentElement.namespaceURI');
29 }
30
31 if (docType)
32 shouldBe('testDocument.doctype', 'testDocType');
33 else
34 shouldBeNull('testDocument.doctype');
35 }
36
37 debug('\nDocumentType createDocumentType(DOMString qualifiedName, DOMString publ icId, DOMString systemId);');
38 shouldThrow('document.implementation.createDocumentType()', "'TypeError: Not eno ugh arguments'");
39 shouldThrow('document.implementation.createDocumentType("qualifiedName")', "'Typ eError: Not enough arguments'");
40 shouldThrow('document.implementation.createDocumentType("qualifiedName", "public Id")', "'TypeError: Not enough arguments'");
41 var docType;
42 shouldNotThrow('docType = document.implementation.createDocumentType("qualifiedN ame", "publicId", "systemId")');
43 shouldBe('docType.__proto__', 'DocumentType.prototype');
44 shouldBeEqualToString('docType.name', 'qualifiedName');
45 shouldBeEqualToString('docType.publicId', 'publicId');
46 shouldBeEqualToString('docType.systemId', 'systemId');
47
48 debug('\nXMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyStri ng] DOMString qualifiedName, DocumentType? doctype);');
49 shouldThrow('document.implementation.createDocument()', "'TypeError: Not enough arguments'");
50 shouldThrow('document.implementation.createDocument("namespace")', "'TypeError: Not enough arguments'");
51 shouldNotThrow('document.implementation.createDocument("namespace", "qualifiedNa me")');
52 var doc;
53 shouldNotThrow('doc = document.implementation.createDocument("namespace", "quali fiedName", null)');
54 validateDocument(doc, 'XMLDocument', 'namespace', 'qualifiedName', null);
55 shouldNotThrow('doc = document.implementation.createDocument(null, "qualifiedNam e", 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", "quali fiedName")');
62 validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", null);
63 shouldNotThrow('doc = document.implementation.createDocument("namespace", "quali fiedName", docType)');
64 validateDocument(doc, 'XMLDocument', "namespace", "qualifiedName", docType);
65
66 debug('\nDocument createHTMLDocument(optional DOMString title);');
67 shouldNotThrow('doc = document.implementation.createHTMLDocument()');
68 validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", do c.doctype);
69 shouldNotThrow('doc = document.implementation.createHTMLDocument("title")');
70 validateDocument(doc, 'HTMLDocument', "http://www.w3.org/1999/xhtml", "HTML", do c.doctype);
71 </script>
72 <script src="../js/resources/js-test-post.js"></script>
73 </body>
74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698