3 <script src="../../http/tests/inspector/inspector-test.js"></script>
8 runtime.loadModulePromise("documentation").then(function() {
9 InspectorTest.runTestSuite([
10 function testWikiParser(next)
13 "{{A|text=<code>it's not a code <code>}}",
15 "{{ABC|Array={{A|B=c}}{{X|y=Z}}|text=blabla}}",
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}}",
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}}"
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());
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);
43 function testSmall(next)
45 var smallTest = "{{Summary_Section|blabla '''oops'''}}";
46 var article = WebInspector.JSArticle.parse(smallTest);
47 InspectorTest.addObject(article);
51 function testHighlightAndLink(next)
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);
59 function testNamedLink(next)
61 var namedLink = "{{Summary_Section| [[url|naaaame]]}}";
62 var article = WebInspector.JSArticle.parse(namedLink);
63 InspectorTest.addObject(article);
67 function testBullet(next)
69 var bulletTest = "{{Summary_Section|*blabla\n*some_text\n*bullet\n}}";
70 var article = WebInspector.JSArticle.parse(bulletTest);
71 InspectorTest.addObject(article);
75 function testRemarks(next)
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);
83 function testComplexLinkName(next)
85 var complexLinkNameTest = "{{Summary_Section| [[url|text <code>blabla</code>\n]]}}";
86 var article = WebInspector.JSArticle.parse(complexLinkNameTest);
87 InspectorTest.addObject(article);
91 function testCodeInsideBullet(next)
93 var codeInsideBullet = "{{Summary_Section|*some text <code>bullet & code </code>}}";
94 var article = WebInspector.JSArticle.parse(codeInsideBullet);
95 InspectorTest.addObject(article);
99 function testInvalidInput(next)
101 var invalidInputTest = "{{Remarks_Section|Remarks=text ]]}}";
102 var article = WebInspector.JSArticle.parse(invalidInputTest);
103 InspectorTest.addResult(article);
107 function testLinkInsideCode(next)
109 var linkInsideCode = "{{Summary_Section|<code> [[https://google.com|GOOGLE!]] </code >}}";
110 var article = WebInspector.JSArticle.parse(linkInsideCode);
111 InspectorTest.addObject(article);
115 function testExamples(next)
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=<!doctype html>\n<html>\n<head>\n<script type{{=}}\"application/javascript\">\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</script>\n</head>\n<body>\n <p onclick{{=}}\"insertElement()\">Click <strong>HERE</strong> to add an item to the following list.</p>\n <ul id{{=}}\"oUL1\">\n <li id{{=}}\"oLIRed\">Red</li>\n <li id{{=}}\"oLIYellow\">Yellow</li>\n <li id{{=}}\"oLIBlue\">Blue</li>\n </ul>\n</body>\n</html>\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);
123 function testJsMethod(next)
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);
131 function testLinkWithoutSpace(next)
133 var linkWithoutSpaceTest = "{{Summary_Section|[[http://google.com|LINK_WITHOUT_SPACE]]}}";
135 var article = WebInspector.JSArticle.parse(linkWithoutSpaceTest);
136 InspectorTest.addObject(article);
138 InspectorTest.addResult("Expected error: " + error);
143 function testEmptyParameters(next)
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);
151 function testTable(next)
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());
164 <body onload="runTest()">