3 <script src="../../../../fast/js/resources/js-test-pre.js"></script>
4 <style id="style" media="screen">
7 clip: rect(0, 0, 1, 1);
8 content: counter(dummy, square);
9 -webkit-transform: translate(10px, 20px);
16 if (window.layoutTestController)
17 layoutTestController.waitUntilDone();
19 function objCWrapperIsInstanceOf(node, className)
21 if (!window.objCController)
22 return "only works under DumpRenderTree";
23 return !!objCController.isObjectInstanceOf(node, className);
26 function objCWrapperClass(node)
28 if (!window.objCController)
29 return "only works under DumpRenderTree";
30 return objCController.className(node);
33 function objCObjectOfClass(name)
35 if (!window.objCController)
36 return "only works under DumpRenderTree";
37 return objCController.objectOfClass(name);
40 function objCArrayOfString()
42 if (!window.objCController)
43 return "only works under DumpRenderTree";
44 return objCController.arrayOfString();
47 function concatenateArray(array)
55 function tagObjCWrapperClass(tagName)
57 return objCWrapperClass(document.createElement(tagName));
60 function testTag(tagName, className, objCClassName)
63 objCClassName = "DOM" + className;
64 if (window.objCController)
65 shouldBe("tagObjCWrapperClass('" + tagName + "')", "'" + objCClassName + "'");
68 function test(expression, className, objCClassName)
71 objCClassName = "DOM" + className;
72 if (window.objCController)
73 shouldBe("objCWrapperClass(" + expression + ")", "'" + objCClassName + "'");
78 // NOTE: This is a sister test to fast/dom/wrapper-class.html which test the JS wrapper classes. Update accordingly.
79 description("This tests wrapper class names for Objective-C.");
81 stylesheet = document.getElementById("style").sheet;
82 root = document.documentElement;
83 xmlDocument = document.getElementById("xmlframe").contentDocument;
88 test("document.createAttribute()", "Attr");
89 test("document.createComment()", "Comment");
90 test("document.createDocumentFragment()", "DocumentFragment");
91 test("document.implementation", "DOMImplementation", "DOMImplementation");
92 test("root.attributes", "NamedNodeMap");
93 test("document.createNodeIterator(root, 0, null, false)", "NodeIterator");
94 test("document.getElementsByTagName('div')", "NodeList");
95 test("document.createRange()", "Range");
96 test("document.createTextNode()", "Text");
97 test("document.createTreeWalker(root, 0, null, false)", "TreeWalker");
103 test("xmlDocument", "Document");
104 test("xmlDocument.createCDATASection()", "CDATASection");
105 test("xmlDocument.createElementNS('x', 'x', 'x')", "Element");
106 test("xmlDocument.createEntityReference()", "EntityReference");
107 test("xmlDocument.createProcessingInstruction()", "ProcessingInstruction");
113 test("document.createEvent('Event')", "Event");
114 test("document.createEvent('KeyboardEvent')", "KeyboardEvent");
115 test("document.createEvent('MouseEvent')", "MouseEvent");
116 test("document.createEvent('MutationEvent')", "MutationEvent");
117 test("document.createEvent('OverflowEvent')", "OverflowEvent");
118 test("document.createEvent('TextEvent')", "TextEvent");
119 test("document.createEvent('UIEvent')", "UIEvent");
120 test("document.createEvent('WheelEvent')", "WheelEvent");
126 test("document.styleSheets", "StyleSheetList");
127 test("stylesheet", "CSSStyleSheet");
128 test("stylesheet.cssRules", "CSSRuleList");
129 test("stylesheet.cssRules.item(0)", "CSSStyleRule");
130 test("stylesheet.cssRules.item(0).style", "CSSStyleDeclaration");
131 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('color')", "CSSPrimitiveValue");
132 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('color').getRGBColorValue()", "RGBColor");
133 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('clip').getRectValue()", "Rect");
134 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('content')", "CSSValueList");
135 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('content').item(0).getCounterValue()", "Counter");
136 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('-webkit-transform')", "CSSValueList");
137 test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('-webkit-transform').item(0)", "WebKitCSSTransformValue");
138 test("stylesheet.media", "MediaList");
144 test("document.createExpression('//*', document.createNSResolver(document))", "XPathExpression");
145 test("document.evaluate('//*', document, document.createNSResolver(document), 0, null)", "XPathResult");
151 test("window", "DOMWindow", "DOMAbstractView");
157 test("root.children", "HTMLCollection");
158 test("document", "HTMLDocument");
159 test("document.createElement('select').options", "HTMLOptionsCollection");
162 debug('HTML Elements');
165 testTag("a", "HTMLAnchorElement");
166 testTag("abbr", "HTMLElement");
167 testTag("acronym", "HTMLElement");
168 testTag("address", "HTMLElement");
169 testTag("applet", "HTMLAppletElement");
170 testTag("area", "HTMLAreaElement");
171 testTag("b", "HTMLElement");
172 testTag("base", "HTMLBaseElement");
173 testTag("basefont", "HTMLBaseFontElement");
174 testTag("bdo", "HTMLElement");
175 testTag("big", "HTMLElement");
176 testTag("blockquote", "HTMLBlockquoteElement", "DOMHTMLElement");
177 testTag("body", "HTMLBodyElement");
178 testTag("br", "HTMLBRElement");
179 testTag("button", "HTMLButtonElement");
180 testTag("canvas", "HTMLCanvasElement");
181 testTag("caption", "HTMLTableCaptionElement");
182 testTag("center", "HTMLElement");
183 testTag("cite", "HTMLElement");
184 testTag("code", "HTMLElement");
185 testTag("col", "HTMLTableColElement");
186 testTag("colgroup", "HTMLTableColElement");
187 testTag("dd", "HTMLElement");
188 testTag("del", "HTMLModElement");
189 testTag("dfn", "HTMLElement");
190 testTag("dir", "HTMLDirectoryElement");
191 testTag("div", "HTMLDivElement");
192 testTag("dl", "HTMLDListElement");
193 testTag("dt", "HTMLElement");
194 testTag("em", "HTMLElement");
195 testTag("embed", "HTMLEmbedElement");
196 testTag("fieldset", "HTMLFieldSetElement");
197 testTag("font", "HTMLFontElement");
198 testTag("form", "HTMLFormElement");
199 testTag("frame", "HTMLFrameElement");
200 testTag("frameset", "HTMLFrameSetElement");
201 testTag("head", "HTMLHeadElement");
202 testTag("h1", "HTMLHeadingElement");
203 testTag("h2", "HTMLHeadingElement");
204 testTag("h3", "HTMLHeadingElement");
205 testTag("h4", "HTMLHeadingElement");
206 testTag("h5", "HTMLHeadingElement");
207 testTag("h6", "HTMLHeadingElement");
208 testTag("hr", "HTMLHRElement");
209 testTag("html", "HTMLHtmlElement");
210 testTag("i", "HTMLElement");
211 testTag("iframe", "HTMLIFrameElement");
212 testTag("image", "HTMLImageElement");
213 testTag("img", "HTMLImageElement");
214 testTag("input", "HTMLInputElement");
215 testTag("ins", "HTMLModElement");
216 testTag("isindex", "HTMLIsIndexElement");
217 testTag("kbd", "HTMLElement");
218 testTag("keygen", "HTMLElement");
219 testTag("label", "HTMLLabelElement");
220 testTag("layer", "HTMLElement");
221 testTag("legend", "HTMLLegendElement");
222 testTag("li", "HTMLLIElement");
223 testTag("link", "HTMLLinkElement");
224 testTag("listing", "HTMLPreElement");
225 testTag("map", "HTMLMapElement");
226 testTag("marquee", "HTMLMarqueeElement");
227 testTag("menu", "HTMLMenuElement");
228 testTag("meta", "HTMLMetaElement");
229 testTag("nobr", "HTMLElement");
230 testTag("noembed", "HTMLElement");
231 testTag("noframes", "HTMLElement");
232 testTag("nolayer", "HTMLElement");
233 testTag("noscript", "HTMLElement");
234 testTag("object", "HTMLObjectElement");
235 testTag("ol", "HTMLOListElement");
236 testTag("optgroup", "HTMLOptGroupElement");
237 testTag("option", "HTMLOptionElement");
238 testTag("p", "HTMLParagraphElement");
239 testTag("param", "HTMLParamElement");
240 testTag("plaintext", "HTMLElement");
241 testTag("pre", "HTMLPreElement");
242 testTag("q", "HTMLQuoteElement");
243 testTag("s", "HTMLElement");
244 testTag("samp", "HTMLElement");
245 testTag("script", "HTMLScriptElement");
246 testTag("select", "HTMLSelectElement");
247 testTag("small", "HTMLElement");
248 testTag("span", "HTMLElement");
249 testTag("strike", "HTMLElement");
250 testTag("strong", "HTMLElement");
251 testTag("style", "HTMLStyleElement");
252 testTag("sub", "HTMLElement");
253 testTag("sup", "HTMLElement");
254 testTag("table", "HTMLTableElement");
255 testTag("tbody", "HTMLTableSectionElement");
256 testTag("td", "HTMLTableCellElement");
257 testTag("textarea", "HTMLTextAreaElement");
258 testTag("tfoot", "HTMLTableSectionElement");
259 testTag("th", "HTMLTableCellElement");
260 testTag("thead", "HTMLTableSectionElement");
261 testTag("title", "HTMLTitleElement");
262 testTag("tr", "HTMLTableRowElement");
263 testTag("tt", "HTMLElement");
264 testTag("u", "HTMLElement");
265 testTag("ul", "HTMLUListElement");
266 testTag("var", "HTMLElement");
267 testTag("wbr", "HTMLElement");
268 testTag("xmp", "HTMLPreElement");
271 debug('JavaScript types');
274 shouldBeTrue("objCWrapperIsInstanceOf(null, 'nil')");
275 shouldBeTrue("objCWrapperIsInstanceOf(undefined, 'WebUndefined')");
276 shouldBeTrue("objCWrapperIsInstanceOf(0, 'NSNumber')");
277 shouldBeTrue("objCWrapperIsInstanceOf(1, 'NSNumber')");
278 shouldBeTrue("objCWrapperIsInstanceOf(false, 'NSNumber')");
279 shouldBeTrue("objCWrapperIsInstanceOf(true, 'NSNumber')");
280 shouldBeTrue("objCWrapperIsInstanceOf('', 'NSString')");
281 shouldBeTrue("objCWrapperIsInstanceOf({ }, 'WebScriptObject')");
282 shouldBeTrue("objCWrapperIsInstanceOf([ ], 'WebScriptObject')");
284 shouldBe("objCObjectOfClass('NSNull')", "null"); // can't test with typeof because typeof null is 'object'
285 shouldBe("typeof objCObjectOfClass('')", "'undefined'");
286 shouldBe("typeof objCObjectOfClass('WebUndefined')", "'undefined'");
287 shouldBe("typeof objCObjectOfClass('NSCFBoolean')", "'boolean'");
288 shouldBe("typeof objCObjectOfClass('NSCFNumber')", "'number'");
289 shouldBe("typeof objCObjectOfClass('NSCFString')", "'string'");
290 shouldBe("typeof objCObjectOfClass('WebScriptObject')", "'object'");
291 shouldBeTrue("objCObjectOfClass('NSArray') instanceof Array");
293 shouldBe("concatenateArray(objCArrayOfString())", "'onetwothree'");
308 // the various window sub-objects
310 // what else is missing?
312 if (window.layoutTestController)
313 layoutTestController.notifyDone();
316 function frameLoaded()
322 <p id="description"></p>
323 <div id="console"></div>
324 <iframe id="xmlframe" onload="frameLoaded()" style="height:0px" src="data:application/xhtml+xml,<?xml version='1.0' encoding='UTF-8'?><body/>"></iframe>