test_bug389797.html (6351B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=389797 5 --> 6 <head> 7 <title>Test for Bug 389797</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389797">Mozilla Bug 389797</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 /** Test for Bug 389797 */ 21 var allTags = []; 22 var classInfos = {}; 23 var interfaces = {}; 24 var interfacesNonClassinfo = {}; 25 26 function getClassName(tag) { 27 return "HTML" + classInfos[tag] + "Element"; 28 } 29 30 function HTML_TAG(aTagName, aImplClass) { 31 allTags.push(aTagName); 32 classInfos[aTagName] = aImplClass; 33 interfaces[aTagName] = []; 34 35 // Some interfaces don't appear in classinfo because other interfaces that 36 // inherit from them do. 37 interfacesNonClassinfo[aTagName] = [ ]; 38 39 if (arguments.length > 2) { 40 for (var i = 0; i < arguments[2].length; ++i) { 41 interfaces[aTagName].push(arguments[2][i]); 42 } 43 } 44 45 if (arguments.length > 3) { 46 for (i = 0; i < arguments[3].length; ++i) { 47 interfacesNonClassinfo[aTagName].push(arguments[3][i]); 48 } 49 } 50 } 51 52 const objectIfaces = [ 53 "nsIRequestObserver", 54 "nsIStreamListener", 55 "nsIObjectLoadingContent", 56 "nsIChannelEventSink", 57 ]; 58 59 /* List copy/pasted from nsHTMLTagList.h, with the second field modified to the 60 correct classinfo (instead of the impl class) in the following cases: 61 62 base 63 blockquote 64 dir 65 dl 66 embed 67 menu 68 ol 69 param 70 q 71 ul 72 wbr 73 head 74 html 75 */ 76 77 HTML_TAG("a", "Anchor"); 78 HTML_TAG("abbr", ""); 79 HTML_TAG("acronym", ""); 80 HTML_TAG("address", ""); 81 HTML_TAG("area", "Area"); 82 HTML_TAG("article", ""); 83 HTML_TAG("aside", ""); 84 HTML_TAG("b", ""); 85 HTML_TAG("base", "Base"); 86 HTML_TAG("bdi", "") 87 HTML_TAG("bdo", ""); 88 HTML_TAG("bgsound", "Unknown"); 89 HTML_TAG("big", ""); 90 HTML_TAG("blockquote", "Quote"); 91 HTML_TAG("body", "Body"); 92 HTML_TAG("br", "BR"); 93 HTML_TAG("button", "Button"); 94 HTML_TAG("canvas", "Canvas"); 95 HTML_TAG("caption", "TableCaption"); 96 HTML_TAG("center", ""); 97 HTML_TAG("cite", ""); 98 HTML_TAG("code", ""); 99 HTML_TAG("col", "TableCol"); 100 HTML_TAG("colgroup", "TableCol"); 101 HTML_TAG("data", "Data"); 102 HTML_TAG("datalist", "DataList"); 103 HTML_TAG("dd", ""); 104 HTML_TAG("del", "Mod"); 105 HTML_TAG("dfn", ""); 106 HTML_TAG("dir", "Directory"); 107 HTML_TAG("div", "Div"); 108 HTML_TAG("dl", "DList"); 109 HTML_TAG("dt", ""); 110 HTML_TAG("em", ""); 111 HTML_TAG("embed", "Embed", [], objectIfaces); 112 HTML_TAG("fieldset", "FieldSet"); 113 HTML_TAG("figcaption", "") 114 HTML_TAG("figure", "") 115 HTML_TAG("font", "Font"); 116 HTML_TAG("footer", "") 117 HTML_TAG("form", "Form"); 118 HTML_TAG("frameset", "FrameSet"); 119 HTML_TAG("h1", "Heading"); 120 HTML_TAG("h2", "Heading"); 121 HTML_TAG("h3", "Heading"); 122 HTML_TAG("h4", "Heading"); 123 HTML_TAG("h5", "Heading"); 124 HTML_TAG("h6", "Heading"); 125 HTML_TAG("head", "Head"); 126 HTML_TAG("header", "") 127 HTML_TAG("hgroup", "") 128 HTML_TAG("hr", "HR"); 129 HTML_TAG("html", "Html"); 130 HTML_TAG("i", ""); 131 HTML_TAG("image", ""); 132 HTML_TAG("img", "Image", [ "nsIImageLoadingContent" ], []); 133 HTML_TAG("input", "Input", [], [ "imgINotificationObserver", 134 "nsIImageLoadingContent" ]); 135 HTML_TAG("ins", "Mod"); 136 HTML_TAG("kbd", ""); 137 HTML_TAG("keygen", "Unknown"); 138 HTML_TAG("label", "Label"); 139 HTML_TAG("legend", "Legend"); 140 HTML_TAG("li", "LI"); 141 HTML_TAG("link", "Link"); 142 HTML_TAG("listing", "Pre"); 143 HTML_TAG("main", ""); 144 HTML_TAG("map", "Map"); 145 HTML_TAG("mark", ""); 146 HTML_TAG("marquee", "Marquee"); 147 HTML_TAG("menu", "Menu"); 148 HTML_TAG("meta", "Meta"); 149 HTML_TAG("meter", "Meter"); 150 HTML_TAG("multicol", "Unknown"); 151 HTML_TAG("nav", "") 152 HTML_TAG("nobr", ""); 153 HTML_TAG("noembed", ""); 154 HTML_TAG("noframes", ""); 155 HTML_TAG("noscript", ""); 156 HTML_TAG("object", "Object", [], objectIfaces); 157 HTML_TAG("ol", "OList"); 158 HTML_TAG("optgroup", "OptGroup"); 159 HTML_TAG("option", "Option"); 160 HTML_TAG("p", "Paragraph"); 161 HTML_TAG("param", "Param"); 162 HTML_TAG("plaintext", ""); 163 HTML_TAG("pre", "Pre"); 164 HTML_TAG("q", "Quote"); 165 HTML_TAG("rb", ""); 166 HTML_TAG("rp", ""); 167 HTML_TAG("rt", ""); 168 HTML_TAG("rtc", ""); 169 HTML_TAG("ruby", ""); 170 HTML_TAG("s", ""); 171 HTML_TAG("samp", ""); 172 HTML_TAG("script", "Script"); 173 HTML_TAG("section", "") 174 HTML_TAG("select", "Select"); 175 HTML_TAG("small", ""); 176 HTML_TAG("span", "Span"); 177 HTML_TAG("strike", ""); 178 HTML_TAG("strong", ""); 179 HTML_TAG("style", "Style"); 180 HTML_TAG("sub", ""); 181 HTML_TAG("sup", ""); 182 HTML_TAG("table", "Table"); 183 HTML_TAG("tbody", "TableSection"); 184 HTML_TAG("td", "TableCell"); 185 HTML_TAG("textarea", "TextArea"); 186 HTML_TAG("tfoot", "TableSection"); 187 HTML_TAG("th", "TableCell"); 188 HTML_TAG("thead", "TableSection"); 189 HTML_TAG("template", "Template"); 190 HTML_TAG("time", "Time"); 191 HTML_TAG("title", "Title"); 192 HTML_TAG("tr", "TableRow"); 193 HTML_TAG("tt", ""); 194 HTML_TAG("u", ""); 195 HTML_TAG("ul", "UList"); 196 HTML_TAG("var", ""); 197 HTML_TAG("wbr", ""); 198 HTML_TAG("xmp", "Pre"); 199 200 function tagName(aTag) { 201 return "<" + aTag + ">"; 202 } 203 204 for (var tag of allTags) { 205 var node = document.createElement(tag); 206 207 // Have to use the proto's toString(), since HTMLAnchorElement and company 208 // override toString(). 209 var nodeString = HTMLElement.prototype.toString.apply(node); 210 211 // Debug builds have extra info, so chop off after "Element" if it's followed 212 // by ' ' or ']' 213 nodeString = nodeString.replace(/Element[\] ].*/, "Element"); 214 215 var classInfoString = getClassName(tag); 216 is(nodeString, "[object " + classInfoString, 217 "Unexpected classname for " + tagName(tag)); 218 is(node instanceof window[classInfoString], true, 219 tagName(tag) + " not an instance of " + classInfos[tag]); 220 221 if (classInfoString != 'HTMLUnknownElement') { 222 is(node instanceof HTMLUnknownElement, false, 223 tagName(tag) + " is an instance of HTMLUnknownElement"); 224 } else { 225 is(node instanceof HTMLUnknownElement, true, 226 tagName(tag) + " is an instance of HTMLUnknownElement"); 227 } 228 229 // Check that each node QIs to all the things we expect it to QI to 230 for (var iface of interfaces[tag].concat(interfacesNonClassinfo[tag])) { 231 is(iface in SpecialPowers.Ci, true, 232 iface + " not in Components.interfaces"); 233 is(node instanceof SpecialPowers.Ci[iface], true, 234 tagName(tag) + " does not QI to " + iface); 235 } 236 } 237 </script> 238 </pre> 239 </body> 240 </html>