Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / parser / resources / p-in-scope.js
blob9f61c551c809d7cf78b490891f49732b62e2bc12
1 function testAsChild(tag)
3     var markup = "<p>1<" + tag + ">";
4     var container = document.createElement("body");
6     container.innerHTML = markup;
8     if (container.childNodes.length == 1)
9         return "allowed";
11     if (container.lastChild.tagName.toLowerCase() == tag)
12         return "closed";
14     return "other";
17 function testAsGrandchild(tag, intermediateTag)
19     var markup = "<p>1<" + intermediateTag + ">2<" + tag + ">3";
20     var container = document.createElement("body");
21     container.innerHTML = markup;
23     if (container.childNodes.length == 1)
24         return "allowed";
25     if (container.firstChild.lastChild && container.firstChild.lastChild.tagName && container.firstChild.lastChild.tagName.toLowerCase() == tag)
26         return "allowed";
28     return "closed";
31 function log(message)
33     document.getElementById("console").appendChild(document.createTextNode(message + "\n\r"));
36 var leafTags = [
37     "address",
38     "blockquote",
39     "center",
40     "dir",
41     "div",
42     "dl",
43     "fieldset",
44     "h1",
45     "h2",
46     "h3",
47     "h4",
48     "h5",
49     "h6",
50     "menu",
51     "ol",
52     "p",
53     "ul",
55     "pre",
56     "listing",
58     "form",
60     "hr",
62     "li",
64     "dd",
65     "dt",
67     "plaintext",
69     "table",
72 var intermediateTags = [
73     "a",            // formatting
75     "b",            // formatting
76     "big",          // formatting
77     "em",           // formatting
78     "i",            // formatting
79     "s",            // formatting
80     "small",        // formatting
81     "strike",       // formatting
82     "strong",       // formatting
83     "tt",           // formatting
84     "u",            // formatting
86     "abbr",
87     "acronym",
88     "bdo",
89     "cite",
90     "code",
91     "dfn",
92     "kbd",
93     "q",
94     "samp",
95     "sub",
96     "sup",
97     "var",
99     "font",         // formatting
101     "nobr",         // formatting
103     "button",       // scoping
105     "object",       // scoping
107     "span",         // phrasing
108     "del",          // phrasing?
109     "ins",          // phrasing?
111     "marquee",      // scoping
114 if (window.testRunner)
115     testRunner.dumpAsText();
117 var headerRow = document.getElementById("header-row");
118 for (var i = 0; i < intermediateTags.length; ++i)
119     headerRow.appendChild(document.createElement("th")).appendChild(document.createTextNode(intermediateTags[i]));
121 for (var i = 0; i < leafTags.length; ++i) {
122     var tag = leafTags[i];
123     var row = document.getElementById("results").appendChild(document.createElement("tr"));
124     row.appendChild(document.createElement("td")).appendChild(document.createTextNode(tag));
125     var asChild = testAsChild(tag);
126     var cell = row.appendChild(document.createElement("td"));
127     cell.className = asChild;
128     cell.appendChild(document.createTextNode(asChild == "allowed" ? "+" : asChild == "closed" ? "-" : "?"));
129     for (var j = 0; j < intermediateTags.length; ++j) {
130         var intermediateTag = intermediateTags[j];
131         var asGrandchild = testAsGrandchild(tag, intermediateTag);
132         cell = row.appendChild(document.createElement("td"));
133         cell.className = asGrandchild;
134         cell.appendChild(document.createTextNode(asGrandchild == "allowed" ? "+" : asGrandchild == "closed" ? "-" : "?"));
135     }