Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / documentation / document-parser.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script>
5
6 function test()
7 {
8     runtime.loadModulePromise("documentation").then(function() {
9         InspectorTest.runTestSuite([
10             function testWikiParser(next)
11             {
12                 var testCases = [
13                     "{{A|text=&lt;code>it's not a code &lt;code>}}",
14                     "{{A|Code={{=}} }}",
15                     "{{ABC|Array={{A|B=c}}{{X|y=Z}}|text=blabla}}",
16                     "{{A|B=C}}",
17                     "{{A|B={{C|D=blablabla}}}}",
18                     "{{A|B={{C|D=bla}}|x=y}}",
19                     "{{CS|Init=black|Values={{CSS Property Value\n|Data Type=color\n|Description= [[css/color|CSS color value]]}}\n}}",
20                     "{{A}}",
21                     "{{A|B= [[http://google.com{{!}}Google]]}}",
22                     "{{AbC|xyz \n\t \r}}",
23                     "{{Notes_Section\n|Notes=Do not specify the ''refChild'' parameter when inserting the first child node. If children already exist and you do not specify the ''refChild'' parameter, the ''newChild'' becomes the last child of the parent object.\nThis method is accessible at run time. If elements are removed at run time, before the closing tag has been parsed, areas of the document might not render.\n}}",
24                     "{{External_Attribution|MSDN_link=[http://msdn.microsoft.com/en-us/library/ie/ms536365(v=vs.85).aspx cloneNode Method]|HTML5Rocks_link=}}",
25                     "{{JS_Syntax|Formats={{JS Syntax Format|Format='''JSON.stringify(''' value [ , replacer] [ , space] ''')'''}}\n}}"
26                 ];
27                 for (var i = 0; i < testCases.length; i++) {
28                     var wikiParser = new WebInspector.WikiParser(testCases[i]);
29                     InspectorTest.addResult("\"" + testCases[i].replace("\r", "\\r") + "\" is parsed");
30                     InspectorTest.addObject(wikiParser.document());
31                 }
32                 next();
33             },
34
35             function testJS(next)
36             {
37                 var jsTest = "{{Remarks_Section\n|Remarks=The optional number1, number2, ..., numberN arguments are numeric expressions to be evaluated.\n\nIf no arguments are provided, the return value is equal to [[javascript/Number/constants{{!}}Number.NEGATIVE_INFINITY]]. If any argument is '''NaN''' , the return value is also '''NaN'''.\n}}";
38                 var article = WebInspector.JSArticle.parse(jsTest);
39                 InspectorTest.addObject(article);
40                 next();
41             },
42
43             function testSmall(next)
44             {
45                 var smallTest = "{{Summary_Section|blabla '''oops'''}}";
46                 var article = WebInspector.JSArticle.parse(smallTest);
47                 InspectorTest.addObject(article);
48                 next();
49             },
50
51             function testHighlightAndLink(next)
52             {
53                 var highlightAndLink = "{{Summary_Section|The '''flex''' CSS property specifies the ability of a flex item to alter its dimensions to fill the available space. '''flex''' is a shorthand property comprised of the [[css/properties/flex-grow|flex-grow]], [[css/properties/flex-shrink|flex-shrink]], and [[css/properties/flex-basis|flex-basis]] properties. A flex item can be stretched to use available space proportional to its flex grow factor, or reduced proportional to its flex shrink factor to prevent overflow.}}";
54                 var article = WebInspector.JSArticle.parse(highlightAndLink);
55                 InspectorTest.addObject(article);
56                 next();
57             },
58
59             function testNamedLink(next)
60             {
61                 var namedLink = "{{Summary_Section| [[url|naaaame]]}}";
62                 var article = WebInspector.JSArticle.parse(namedLink);
63                 InspectorTest.addObject(article);
64                 next();
65             },
66
67             function testBullet(next)
68             {
69                 var bulletTest = "{{Summary_Section|*blabla\n*some_text\n*bullet\n}}";
70                 var article = WebInspector.JSArticle.parse(bulletTest);
71                 InspectorTest.addObject(article);
72                 next();
73             },
74
75             function testRemarks(next)
76             {
77                 var remarksTest = "{{Remarks_Section\n|Remarks=In JavaScript arrays are sparse, and the elements in an array do not have to be contiguous. The '''length''' property is not necessarily the number of elements in the array. For example, in the following array definition, <code>my_array.length</code> contains 7, not 2:\n\n var my_array = new Array( );\n my_array[0] = \"Test\";\n my_array[6] = \"Another Test\";\n console.log(my_array.length);\n \n // Output\n // 7\nEven if you set length to a number greater than its previous value, the number of actual elements does not increase.\n\n console.log(my_array.length); // 7\n my_array.length = 10;\n console.log(Object.keys(my_array));\n \n // Output\n // [\"0\", \"6\"]\nOn the other hand, when decreasing length, the array is truncated.\n\n console.log(my_array.length); // 10\n my_array.length = 1;\n console.log(Object.keys(my_array));\n \n // Output\n // [\"0\"]\n}}";
78                 var article = WebInspector.JSArticle.parse(remarksTest);
79                 InspectorTest.addObject(article);
80                 next();
81             },
82
83             function testComplexLinkName(next)
84             {
85                 var complexLinkNameTest = "{{Summary_Section| [[url|text <code>blabla</code>\n]]}}";
86                 var article = WebInspector.JSArticle.parse(complexLinkNameTest);
87                 InspectorTest.addObject(article);
88                 next();
89             },
90
91             function testCodeInsideBullet(next)
92             {
93                 var codeInsideBullet = "{{Summary_Section|*some text <code>bullet & code </code>}}";
94                 var article = WebInspector.JSArticle.parse(codeInsideBullet);
95                 InspectorTest.addObject(article);
96                 next();
97             },
98
99             function testInvalidInput(next)
100             {
101                 var invalidInputTest = "{{Remarks_Section|Remarks=text ]]}}";
102                 var article = WebInspector.JSArticle.parse(invalidInputTest);
103                 InspectorTest.addResult(article);
104                 next();
105             },
106
107             function testLinkInsideCode(next)
108             {
109                 var linkInsideCode = "{{Summary_Section|<code> [[https://google.com|GOOGLE!]] </code >}}";
110                 var article = WebInspector.JSArticle.parse(linkInsideCode);
111                 InspectorTest.addObject(article);
112                 next();
113             },
114
115             function testExamples(next)
116             {
117                 var examplesTest = "{{Examples_Section\n|Not_required=No\n|Examples={{Single Example\n|Language=HTML\n|Description=The following example shows how to use the '''insertBefore''' method to insert a new item into an existing list.\n|Code=&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;script type{{=}}\"application/javascript\"&gt;\n    function insertElement()\n    {\n        var nod{{=}}document.createElement(\"li\");\n        document.getElementById(\"oUL1\").insertBefore(nod, document.getElementById(\"oLIYellow\"));\n        nod.textContet{{=}}\"Orange\";\n    }\n&lt;/script&gt;\n&lt;/head&gt;\n&lt;body&gt;\n    &lt;p onclick{{=}}\"insertElement()\"&gt;Click &lt;strong&gt;HERE&lt;/strong&gt; to add an item to the following list.&lt;/p&gt;\n    &lt;ul id{{=}}\"oUL1\"&gt;\n        &lt;li id{{=}}\"oLIRed\"&gt;Red&lt;/li&gt;\n        &lt;li id{{=}}\"oLIYellow\"&gt;Yellow&lt;/li&gt;\n        &lt;li id{{=}}\"oLIBlue\"&gt;Blue&lt;/li&gt;\n    &lt;/ul&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n|LiveURL=http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/insertBefore.htm\n}}\n}}";
118                 var article = WebInspector.JSArticle.parse(examplesTest);
119                 InspectorTest.addObject(article);
120                 next();
121             },
122
123             function testJsMethod(next)
124             {
125                 var jsMethodTest = "{{API_Object_Method\n|Parameters={{Method Parameter\n|Name=newNode\n|Data type=DOM Node\n|Description=The new node to be inserted.\n|Optional=No\n}}{{Method Parameter\n|Name=refChild\n|Data type=DOM Node\n|Description=Supplies the placement of the new node. If this parameter is specified, the new element will be inserted immediately before this existing child node. If not, it will be added after the last child node.\n|Optional=Yes\n}}\n|Method_applies_to=dom/Node\n|Example_object_name=node\n|Return_value_name=insertedNode\n|Javascript_data_type=DOM Node\n|Return_value_description=The inserted node.\n}}\n";
126                 var article = WebInspector.JSArticle.parse(jsMethodTest);
127                 InspectorTest.addObject(article);
128                 next();
129             },
130
131             function testLinkWithoutSpace(next)
132             {
133                 var linkWithoutSpaceTest = "{{Summary_Section|[[http://google.com|LINK_WITHOUT_SPACE]]}}";
134                 try {
135                     var article = WebInspector.JSArticle.parse(linkWithoutSpaceTest);
136                     InspectorTest.addObject(article);
137                 } catch (error) {
138                     InspectorTest.addResult("Expected error: " + error);
139                 }
140                 next();
141             },
142
143             function testEmptyParameters(next)
144             {
145                 var emptyParameterTest = "{{API_Object_Method\n|Parameters=\n|Method_applies_to=dom/shadowdom/ShadowRoot\n|Javascript_data_type=DOM Node\n|Return_value_description=Returns the DOM node specified by the given ID. Case matters, and if there is more than one node with the given ID, which node is returned is uncertain.\n}}";
146                 var article = WebInspector.JSArticle.parse(emptyParameterTest);
147                 InspectorTest.addObject(article);
148                 next();
149             },
150
151             function testTable(next)
152             {
153                 var tableTest = "{{Table|there is a table \n{{{!}} class='wikitable' \n{{!}}-\n! A\n! B\n! C\n{{!}}-\n{{!}} 1\n{{!}} 2\n{{!}} 3\n{{!}}-\n{{!}} 4\n{{!}} 5\n{{!}} 6\n{{!}}}\n}}";
154                 var wikiParser = new WebInspector.WikiParser(tableTest);
155                 InspectorTest.addObject(wikiParser.document());
156                 next();
157             }
158         ]);
159     }).done();
160 }
161 </script>
162 </head>
163
164 <body onload="runTest()">
165
166 </body>
167 </html>