Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / documentation / document-parser.html
index 02d74fb..2378205 100644 (file)
 function test()
 {
     InspectorTest.registerModule("documentation", true);
-    var testCases = [
-        "{{A|B={{C|D=blablabla}}}}",
-        "{{CS|Init=black|Values={{CSS Property Value\n|Data Type=color\n|Description=[[css/color|CSS color value]]}}\n}}",
-        "{{A}}",
-        "{{A|B=bla<a=c>bla}}",
-        "{{A}}",
-        "{{AbC|xyz \n \t \r}}"];
-    for (var i = 0; i < testCases.length; i++) {
-        var wikiParser = new WebInspector.WikiParser(testCases[i]);
-        InspectorTest.addResult("\"" + testCases[i].replace("\r", "\\r") + "\" is parsed");
-        InspectorTest.addObject(wikiParser.document());
-    }
-
-    var jsTest = "{{Page_Title}}\n{{Flags}}\n{{Summary_Section|Returns the larger of a set of supplied numeric expressions.\n\n}}\n{{JS_Syntax|Formats={{JS_Syntax_Format\n|Format= Math.max([ number1 [, number2 [... [, numberN ]]]]) }}\n}}\n{{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}}\n{{Examples_Section\n|Not_required=No\n|Examples={{Single_Example\n|Language=JavaScript\n|Description=The following code shows how to get the larger of two expressions.\n\n|Code= var x = Math.max(107 - 3,  48 * 90);\n document.write(x);\n \n // Output:\n // 4320\n}}}}\n{{See_Also_Section\n|Manual_links=* [[javascript/Math/min{{!}}Math.min Function]]\n}}\n{{Topics | JS Basic}}\n\n{{External_Attribution\n|Is_CC-BY-SA=No\n|Sources=MSDN\n|MDN_link=\n|MSDN_link=http://msdn.microsoft.com/en-us/library/ie/yek4tbz0%28v=vs.94%29.aspx Windows Internet Explorer JavaScript reference\n|HTML5Rocks_link=\n}}";
-    var article = WebInspector.JSArticle.parse(jsTest);
-    InspectorTest.addObject(article);
-
-    var cssTest = "{{Page_Title}}\n{{Flags\n|State=Ready to Use\n|Checked_Out=No\n}}\n{{Standardization_Status|W3C Recommendation}}\n{{API_Name}}\n{{Summary_Section|The color property sets the color of an element's foreground content (usually text), accepting any standard CSS color from keywords and hex values to RGB(a) and HSL(a).}}\n{{CSS Property\n|Initial value=black, except in a few cases (see notes)\n|Applies to=All elements\n|Inherited=Yes\n|Media=visual\n|Computed value=For a non-translucent color, an hexadecimal equivalent is used. Otherwise it is the RGBa equivalent\n|Animatable=Yes\n|CSS object model property=color\n|CSS percentages=NA\n|Values={{CSS Property Value\n|Data Type=color\n|Description=[[css/color|CSS color value]]\n}}\n}}\n{{Examples_Section\n|Not_required=No\n|Examples={{Single Example\n|Language=CSS\n|Code=/* Setting a paragraph color to turquoise with a name value */\np {color:turquoise}\n\n/* Setting the same propriety with an hexadecimal value*/\np {color:#40E0D0}\n\n/* with a RGB decimal value */\np { color: rgb(64,224,208) }\n\n/* with a RGB percentage value */\np { color: rgb(25.1%,87.8%,81.6%) }\n\n/* with an HSL value */\np { color: hsl(174,72%,56%) }\n\n/* We now want our color to be 20% translucent which means a 80% opacity */\n\n/* We can achieve this with an RGBa value */ \np { color: rgba(64,224,208,0.8) }\n\n/* Or an HSLa value */\np { color: hsla(174,72%,56%,0.8) }\n|LiveURL=http://code.webplatform.org/gist/5502992\n}}\n}}\n{{Notes_Section\n|Usage=Though CSS color values are precisely defined, they may appear differently between different output devices. Most of them are not calibrated, and some browsers do not support output device color profiles. Without these, color rendering may vary significantly.\n|Notes==== Default color ===\nSome browsers change the default color from black to another color in their default css (user-agent stylesheet).\n\n=== RGB, HSL, RGBa and HSLa support ===\nHSL, RGBa and HSLa are not supported by older browsers (IE6-8), therefore if you do use such colours you should also provide a fallback color property that uses something similar but more widely supported, like a hex value. This should be placed either next to the modern color value but earlier in the cascade, or in a separate stylesheet hidden behind a conditional comment.\n\n=== Separating foreground from background ===\nIn order to make it easier for users to see and hear content including separating foreground from background, [[http://www.w3.org/TR/2008/REC-WCAG20-20081211/ WCAG]] indicates the following:\n* color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element. [[http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-without-color Guideline 1.4.1]] (Level A)\n* The visual presentation of text and images of text has a minimum contrast ratio of at least 4.5:1, with some exceptions. [[http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast Contrast Minimum Guideline 1.4.3]] (Level AA)\n* The visual presentation of text and images of text has an enhanced contrast ratio of at least 7:1 [[http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast7 Guideline 1.4.6]] (Level AAA)\n}}\n{{Related_Specifications_Section\n|Specifications={{Related Specification\n|Name=CSS3 Color Module Level 3\n|URL=http://www.w3.org/TR/css3-color/\n|Status=W3C Recommendation\n}}{{Related Specification\n|Name=Color in CSS1\n|URL=http://www.w3.org/TR/REC-CSS1/#color\n|Status=W3C Recommendation\n}}\n}}\n{{Compatibility_Section\n|Not_required=No\n|Imported_tables=\n|Desktop_rows={{Compatibility Table Desktop Row\n|Feature=Keywords and hexadecimals colors\n|Chrome_supported=Yes\n|Chrome_version=1.0\n|Chrome_prefixed_supported=No\n|Chrome_prefixed_version=\n|Firefox_supported=Yes\n|Firefox_version=1.0\n|Firefox_prefixed_supported=No\n|Firefox_prefixed_version=\n|Internet_explorer_supported=Yes\n|Internet_explorer_version=3.0\n|Internet_explorer_prefixed_supported=No\n|Internet_explorer_prefixed_version=\n|Opera_supported=Yes\n|Opera_version=3.5\n|Opera_prefixed_supported=No\n|Opera_prefixed_version=\n|Safari_supported=Yes\n|Safari_version=1.0\n|Safari_prefixed_supported=No\n|Safari_prefixed_version=\n}}{{Compatibility Table Desktop Row\n|Feature=RGB\n|Chrome_supported=Yes\n|Chrome_version=1.0\n|Chrome_prefixed_supported=No\n|Chrome_prefixed_version=\n|Firefox_supported=Yes\n|Firefox_version=1.0\n|Firefox_prefixed_supported=No\n|Firefox_prefixed_version=\n|Internet_explorer_supported=Yes\n|Internet_explorer_version=4.0\n|Internet_explorer_prefixed_supported=No\n|Internet_explorer_prefixed_version=\n|Opera_supported=Yes\n|Opera_version=3.5\n|Opera_prefixed_supported=No\n|Opera_prefixed_version=\n|Safari_supported=Yes\n|Safari_version=1.0\n|Safari_prefixed_supported=No\n|Safari_prefixed_version=\n}}{{Compatibility Table Desktop Row\n|Feature=HSL\n|Chrome_supported=Yes\n|Chrome_version=1.0\n|Chrome_prefixed_supported=No\n|Chrome_prefixed_version=\n|Firefox_supported=Yes\n|Firefox_version=1.0\n|Firefox_prefixed_supported=No\n|Firefox_prefixed_version=\n|Internet_explorer_supported=Yes\n|Internet_explorer_version=9.0\n|Internet_explorer_prefixed_supported=No\n|Internet_explorer_prefixed_version=\n|Opera_supported=Yes\n|Opera_version=9.5\n|Opera_prefixed_supported=No\n|Opera_prefixed_version=\n|Safari_supported=Yes\n|Safari_version=3.1\n|Safari_prefixed_supported=Unknown\n|Safari_prefixed_version=\n}}{{Compatibility Table Desktop Row\n|Feature=Translucent color value (RGBa, HSLa)\n|Chrome_supported=Yes\n|Chrome_version=1.0\n|Chrome_prefixed_supported=No\n|Chrome_prefixed_version=\n|Firefox_supported=Yes\n|Firefox_version=3.0\n|Firefox_prefixed_supported=No\n|Firefox_prefixed_version=\n|Internet_explorer_supported=Yes\n|Internet_explorer_version=9\n|Internet_explorer_prefixed_supported=No\n|Internet_explorer_prefixed_version=\n|Opera_supported=Yes\n|Opera_version=10\n|Opera_prefixed_supported=No\n|Opera_prefixed_version=\n|Safari_supported=Yes\n|Safari_version=3.0\n|Safari_prefixed_supported=Unknown\n|Safari_prefixed_version=\n}}\n|Mobile_rows={{Compatibility Table Mobile Row\n|Android_supported=Yes\n|Android_version=1.0\n|Android_prefixed_supported=No\n|Android_prefixed_version=\n|Blackberry_supported=Yes\n|Blackberry_version=3.8\n|Blackberry_prefixed_supported=No\n|Blackberry_prefixed_version=\n|Chrome_mobile_supported=Yes\n|Chrome_mobile_version=1.0\n|Chrome_mobile_prefixed_supported=No\n|Chrome_mobile_prefixed_version=\n|Firefox_mobile_supported=Yes\n|Firefox_mobile_version=1.0\n|Firefox_mobile_prefixed_supported=No\n|Firefox_mobile_prefixed_version=\n|IE_mobile_supported=Yes\n|IE_mobile_version=6.0\n|IE_mobile_prefixed_supported=No\n|IE_mobile_prefixed_version=\n|Opera_mobile_supported=Yes\n|Opera_mobile_version=6.0\n|Opera_mobile_prefixed_supported=No\n|Opera_mobile_prefixed_version=\n|Opera_mini_supported=Yes\n|Opera_mini_prefixed_supported=No\n|Opera_mini_prefixed_version=\n|Safari_mobile_supported=Yes\n|Safari_mobile_version=1.0\n|Safari_mobile_prefixed_supported=No\n|Safari_mobile_prefixed_version=\n}}{{Compatibility Table Mobile Row\n|Feature=Translucent color value (RGBa, HSLa)\n|Android_supported=Yes\n|Android_version=2.1\n|Android_prefixed_supported=No\n|Android_prefixed_version=\n|Blackberry_supported=Yes\n|Blackberry_version=7.0\n|Blackberry_prefixed_supported=No\n|Blackberry_prefixed_version=\n|Chrome_mobile_supported=Yes\n|Chrome_mobile_version=18\n|Chrome_mobile_prefixed_supported=No\n|Chrome_mobile_prefixed_version=\n|Firefox_mobile_supported=Yes\n|Firefox_mobile_version=18\n|Firefox_mobile_prefixed_supported=No\n|Firefox_mobile_prefixed_version=\n|IE_mobile_supported=Yes\n|IE_mobile_version=9\n|IE_mobile_prefixed_supported=No\n|IE_mobile_prefixed_version=\n|Opera_mobile_supported=Yes\n|Opera_mobile_version=10\n|Opera_mobile_prefixed_supported=No\n|Opera_mobile_prefixed_version=\n|Opera_mini_supported=Yes\n|Opera_mini_version=5.0\n|Opera_mini_prefixed_supported=No\n|Opera_mini_prefixed_version=\n|Safari_mobile_supported=Yes\n|Safari_mobile_version=3.2\n|Safari_mobile_prefixed_supported=Unknown\n|Safari_mobile_prefixed_version=\n}}\n|Notes_rows={{Compatibility Notes Row\n|Browser=Internet Explorer\n|Version=<=7.0\n|Note=no support for the \"inherit\" value\n}}\n}}\n{{See_Also_Section\n|Manual_links=* [[tutorials/setting_color_in_css|Setting color in CSS]]\n* [[css/color|color]]\n* [[css/data_types/color|color]]\n|Manual_sections=*[http://www.w3.org/Style/CSS/Test/CSS3/Color/current/ W3 css3-color Conformance Test Suite]\n*[https://developer.mozilla.org/en-US/docs/CSS/color MDN color property]\n*[http://msdn.microsoft.com/en-us/library/ie/ms530749(v=vs.85).aspx MSDN color property]\n}}\n{{Topics|CSS}}\n{{External_Attribution\n|Is_CC-BY-SA=No\n|MDN_link=\n|MSDN_link=\n|HTML5Rocks_link=\n}}";
-    article = WebInspector.CSSArticle.parse(cssTest);
-    InspectorTest.addObject(article);
-
-    InspectorTest.completeTest();
-}
 
+    InspectorTest.runTestSuite([
+        function testWikiParser(next)
+        {
+            var testCases = [
+                "{{A|text=&lt;code>it's not a code &lt;code>}}",
+                "{{A|Code={{=}} }}",
+                "{{ABC|Array={{A|B=c}}{{X|y=Z}}|text=blabla}}",
+                "{{A|B=C}}",
+                "{{A|B={{C|D=blablabla}}}}",
+                "{{A|B={{C|D=bla}}|x=y}}",
+                "{{CS|Init=black|Values={{CSS Property Value\n|Data Type=color\n|Description= [[css/color|CSS color value]]}}\n}}",
+                "{{A}}",
+                "{{A|B= [[http://google.com{{!}}Google]]}}",
+                "{{AbC|xyz \n\t \r}}",
+                "{{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}}",
+                "{{External_Attribution|MSDN_link=[http://msdn.microsoft.com/en-us/library/ie/ms536365(v=vs.85).aspx cloneNode Method]|HTML5Rocks_link=}}",
+                "{{JS_Syntax|Formats={{JS Syntax Format|Format='''JSON.stringify(''' value [ , replacer] [ , space] ''')'''}}\n}}"
+            ];
+            for (var i = 0; i < testCases.length; i++) {
+                var wikiParser = new WebInspector.WikiParser(testCases[i]);
+                InspectorTest.addResult("\"" + testCases[i].replace("\r", "\\r") + "\" is parsed");
+                InspectorTest.addObject(wikiParser.document());
+            }
+            next();
+        },
+
+        function testJS(next)
+        {
+            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}}";
+            var article = WebInspector.JSArticle.parse(jsTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testSmall(next)
+        {
+            var smallTest = "{{Summary_Section|blabla '''oops'''}}";
+            var article = WebInspector.JSArticle.parse(smallTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testHighlightAndLink(next)
+        {
+            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.}}";
+            var article = WebInspector.JSArticle.parse(highlightAndLink);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testNamedLink(next)
+        {
+            var namedLink = "{{Summary_Section| [[url|naaaame]]}}";
+            var article = WebInspector.JSArticle.parse(namedLink);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testBullet(next)
+        {
+            var bulletTest = "{{Summary_Section|*blabla\n*some_text\n*bullet\n}}";
+            var article = WebInspector.JSArticle.parse(bulletTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testRemarks(next)
+        {
+            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}}";
+            var article = WebInspector.JSArticle.parse(remarksTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testComplexLinkName(next)
+        {
+            var complexLinkNameTest = "{{Summary_Section| [[url|text <code>blabla</code>\n]]}}";
+            var article = WebInspector.JSArticle.parse(complexLinkNameTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testCodeInsideBullet(next)
+        {
+            var codeInsideBullet = "{{Summary_Section|*some text <code>bullet & code </code>}}";
+            var article = WebInspector.JSArticle.parse(codeInsideBullet);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testInvalidInput(next)
+        {
+            var invalidInputTest = "{{Remarks_Section|Remarks=text ]]}}";
+            var article = WebInspector.JSArticle.parse(invalidInputTest);
+            InspectorTest.addResult(article);
+            next();
+        },
+
+        function testLinkInsideCode(next)
+        {
+            var linkInsideCode = "{{Summary_Section|<code> [[https://google.com|GOOGLE!]] </code >}}";
+            var article = WebInspector.JSArticle.parse(linkInsideCode);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testExamples(next)
+        {
+            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}}";
+            var article = WebInspector.JSArticle.parse(examplesTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testJsMethod(next)
+        {
+            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";
+            var article = WebInspector.JSArticle.parse(jsMethodTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testLinkWithoutSpace(next)
+        {
+            var linkWithoutSpaceTest = "{{Summary_Section|[[http://google.com|LINK_WITHOUT_SPACE]]}}";
+            try {
+                var article = WebInspector.JSArticle.parse(linkWithoutSpaceTest);
+                InspectorTest.addObject(article);
+            } catch (error) {
+                InspectorTest.addResult("Expected error: " + error);
+            }
+            next();
+        },
+
+        function testEmptyParameters(next)
+        {
+            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}}";
+            var article = WebInspector.JSArticle.parse(emptyParameterTest);
+            InspectorTest.addObject(article);
+            next();
+        },
+
+        function testTable(next)
+        {
+            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}}";
+            var wikiParser = new WebInspector.WikiParser(tableTest);
+            InspectorTest.addObject(wikiParser.document());
+            next();
+        }
+    ]);
+}
 </script>
 </head>