Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / document-attribute-js-null.html
blobde379ef30fa730f5dd4c1f48842afaca2692a053
1 <html>
2 <head>
3 <style type="text/css">
4 .pass { color: green; }
5 .fail { color: red; }
6 </style>
7 <script>
8 function printOut(msg)
10 var console = document.getElementById("console");
11 var span = document.createElement('span');
12 span.innerHTML = msg + '<br>';
13 console.appendChild(span);
16 function resultStringifier(result)
18 if (result === "")
19 return "<b>the empty string</b>";
20 else if (result === null)
21 return "<b>null</b>";
22 else if (result === undefined)
23 return "<b>undefined</b>";
24 return "the string '" + result + "'";
27 function nullTestDocumentAttribute(documentType, doc, attr, expected, expectedExceptionCode)
29 var result;
30 try {
31 doc[attr] = null;
32 if (expectedExceptionCode != undefined)
33 result = "<span class='fail'>TEST FAILED:</span> Should've thrown " + expectedExceptionCode + " but threw nothing.";
34 else if (doc[attr] === expected)
35 result = "<span class='pass'>TEST SUCCEEDED:</span> The value was " + resultStringifier(expected) + ".";
36 else
37 result = "<span class='fail'>TEST FAILED:</span> The value should have been " + resultStringifier(expected) + " but was " + resultStringifier(doc[attr]) + ".";
39 } catch (ex) {
40 if (ex.code == expectedExceptionCode)
41 result = "<span class='pass'>TEST SUCCEEDED:</span> Got the expected exception (" + ex.code + ").";
42 else
43 result = "<span class='fail'>TEST FAILED:</span> Should've thrown " + expectedExceptionCode + " but threw " + ex.code + ".";
46 result += " [tested " + documentType + "." + attr + "]";
47 printOut(result);
50 function runTests()
52 if (window.testRunner)
53 testRunner.dumpAsText();
55 // Others to test:
56 // Functions
58 var xmlDoc = document.implementation.createDocument(null, null, null);
59 var htmlDoc = document.implementation.createHTMLDocument('A Title');
60 htmlDoc.body = htmlDoc.createElement('body');
62 var listing = [
64 typeName: 'Document',
65 docToUse: xmlDoc,
66 attributes: [
67 {name: 'xmlVersion', expectedExceptionCode: 9},
68 {name: 'documentURI', expectedNull: null},
69 {name: 'charset', expectedNull: 'UTF-8'},
70 {name: 'defaultCharset', expectedNull: undefined},
71 {name: 'characterSet', expectedNull: 'UTF-8'},
72 {name: 'inputEncoding', expectedNull: 'UTF-8'},
73 {name: 'selectedStylesheetSet', expectedNull: null}
77 typeName: 'HTMLDocument',
78 docToUse: htmlDoc,
79 attributes: [
80 {name: 'title', expectedNull: ''},
81 {name: 'cookie', expectedNull: ''},
82 {name: 'bgColor', expectedNull: ''},
83 {name: 'fgColor', expectedNull: ''},
84 {name: 'alinkColor', expectedNull: ''},
85 {name: 'linkColor', expectedNull: ''},
86 {name: 'vlinkColor', expectedNull: ''},
87 {name: 'dir', expectedNull: ''},
88 {name: 'designMode', expectedNull: 'off'}
93 for (doc in listing) {
94 var typeName = listing[doc].typeName;
95 var docToUse = listing[doc].docToUse;
96 var attrs = listing[doc].attributes;
97 for (attr in attrs) {
98 nullTestDocumentAttribute(typeName, docToUse, attrs[attr].name, attrs[attr].expectedNull, attrs[attr].expectedExceptionCode);
100 printOut('');
103 </script>
104 </head>
105 <body onload="runTests()">
106 <p>This test setting various attributes of documents to JavaScript null.</p>
107 <div id="console"></div>
108 </body>
109 </html>