tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / platform / mac / fast / dom / wrapper-classes-objc.html
1 <html>
2 <head>
3 <script src="../../../../fast/js/resources/js-test-pre.js"></script>
4 <style id="style" media="screen">
5 .non-existent-class {
6     color: rgb(0, 0, 0);
7     clip: rect(0, 0, 1, 1);
8     content: counter(dummy, square);
9     -webkit-transform: translate(10px, 20px);
10 }
11 </style>
12 </head>
13 <body>
14 <script>
15
16 if (window.layoutTestController)
17     layoutTestController.waitUntilDone();
18
19 function objCWrapperIsInstanceOf(node, className)
20 {
21     if (!window.objCController)
22         return "only works under DumpRenderTree";
23     return !!objCController.isObjectInstanceOf(node, className);
24 }
25
26 function objCWrapperClass(node)
27 {
28     if (!window.objCController)
29         return "only works under DumpRenderTree";
30     return objCController.className(node);
31 }
32
33 function objCObjectOfClass(name)
34 {
35     if (!window.objCController)
36         return "only works under DumpRenderTree";
37     return objCController.objectOfClass(name);
38 }
39
40 function objCArrayOfString()
41 {
42     if (!window.objCController)
43         return "only works under DumpRenderTree";
44     return objCController.arrayOfString();
45 }
46
47 function concatenateArray(array)
48 {
49     var result = '';
50     for (i in array)
51         result += array[i];
52     return result;
53 }
54
55 function tagObjCWrapperClass(tagName)
56 {
57     return objCWrapperClass(document.createElement(tagName));
58 }
59
60 function testTag(tagName, className, objCClassName)
61 {
62     if (!objCClassName)
63         objCClassName = "DOM" + className;
64     if (window.objCController)
65         shouldBe("tagObjCWrapperClass('" + tagName + "')", "'" + objCClassName + "'");
66 }
67
68 function test(expression, className, objCClassName)
69 {
70     if (!objCClassName)
71         objCClassName = "DOM" + className;
72     if (window.objCController)
73         shouldBe("objCWrapperClass(" + expression + ")", "'" + objCClassName + "'");
74 }
75
76 function runTest()
77 {
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.");
80
81     stylesheet = document.getElementById("style").sheet;
82     root = document.documentElement;
83     xmlDocument = document.getElementById("xmlframe").contentDocument;
84
85     debug('Basics');
86     debug('');
87
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");
98
99     debug('');
100     debug('XML');
101     debug('');
102
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");
108
109     debug('');
110     debug('Events');
111     debug('');
112
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");
121
122     debug('');
123     debug('CSS DOM');
124     debug('');
125
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");
139
140     debug('');
141     debug('XPath');
142     debug('');
143
144     test("document.createExpression('//*', document.createNSResolver(document))", "XPathExpression");
145     test("document.evaluate('//*', document, document.createNSResolver(document), 0, null)", "XPathResult");
146
147     debug('');
148     debug('Other');
149     debug('');
150
151     test("window", "DOMWindow", "DOMAbstractView");
152
153     debug('');
154     debug('HTML DOM');
155     debug('');
156
157     test("root.children", "HTMLCollection");
158     test("document", "HTMLDocument");
159     test("document.createElement('select').options", "HTMLOptionsCollection");
160
161     debug('');
162     debug('HTML Elements');
163     debug('');
164
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");
269     
270     debug('');
271     debug('JavaScript types');
272     debug('');
273
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')");
283
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");
292
293     shouldBe("concatenateArray(objCArrayOfString())", "'onetwothree'");
294
295     // Not yet tested:
296
297     // CSSCharsetRule
298     // CSSFontFaceRule
299     // CSSImportRule
300     // CSSMediaRule
301     // CSSPageRule
302     // CSSRule
303     // CSSValue
304     // SVGColor
305     // SVGPaint
306     // SVGZoomEvent
307
308     // the various window sub-objects
309
310     // what else is missing?
311
312     if (window.layoutTestController)
313         layoutTestController.notifyDone();
314 }
315
316 function frameLoaded()
317 {
318     runTest();
319 }
320
321 </script>
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>
325 </body>
326 </html>