4 <div id=
"test" contenteditable
></div>
9 <dd id=
"preserved"></dd>
11 <dd id=
"exceptions"></dd>
13 <script type=
"text/javascript">
15 if (window
.testRunner
)
16 testRunner
.dumpAsText();
18 var elements
= [ "noscript", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio",
19 "b", "base", "basefont", "bdo", "bgsound", "big", "blockquote", "body", "br", "button",
20 "canvas", ["table", "caption"], "center", "cite", "code", ["table", "col"], ["table", "colgroup"], "command",
21 "datagrid", "datalist", "dcell", "dcol", "dd", "del", "details", "dfn", "dir", "div", "dl", "drow", "dt",
22 "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset",
23 "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html",
24 "i", "iframe", "image", "img", "input", "ins", "isindex", "kbd", "keygen", "label", "layer", "legend", ["ul", "li"], "link", "listing",
25 "main", "map", "mark", "marquee", "menu", "meta", "meter", "nav", "nobr", "noembed", "noframes", "nolayer", "noscript",
26 "object", "ol", "optgroup", "option", "p", "param", "plaintext", "pre", "progress", "q", "rp", "rt", "ruby",
27 "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup",
28 "table", ["table", "tbody"], ["table", "td"], "textarea", ["table", "tfoot"], ["table", "th"], ["table", "thead"],
29 "title", ["table", "tr"], "track", "tt", "u", "ul", "var", "video", "wbr", "xmp" ];
31 function addResult(container
, name
, annotation
, description
)
33 if (container
.innerHTML
.length
&& !annotation
)
34 container
.innerHTML
+= ', ';
35 container
.innerHTML
+= name
;
37 container
.appendChild(document
.createTextNode(" (" + annotation
+ ")"));
39 container
.appendChild(document
.createTextNode(description
));
40 if (annotation
|| description
)
41 container
.appendChild(document
.createElement('br'));
44 function contains(node
, descendant
)
46 while (descendant
&& descendant
!= node
&& descendant
.parentNode
)
47 descendant
= descendant
.parentNode
;
48 return descendant
== node
;
51 var test
= document
.getElementById('test');
52 for (var i
= 0; i
< elements
.length
; i
++) {
56 if (typeof elements
[i
] == 'string') {
57 elementName
= elements
[i
];
58 instance
= document
.createElement(elementName
)
61 var elementList
= elements
[i
];
62 for (var j
= 0; j
< elementList
.length
; j
++) {
63 var node
= document
.createElement(elementList
[j
]);
67 instance
.appendChild(node
);
70 elementName
= elementList
[elementList
.length
- 1];
72 var dummy_text
= document
.createTextNode('hello=1;');
73 if (instance
=== undefined) {
74 addResult(document
.getElementById('exceptions'), elementName
, test
.innerHTML
);
79 instance
.appendChild(dummy_text
); // this may fail for non-container elements.
81 test
.appendChild(container
);
82 test
.appendChild(document
.createTextNode(' webkit=2;'));
84 if (window
.getSelection
) {
85 window
.getSelection().selectAllChildren(test
);
87 var range
= document
.body
.createTextRange();
88 range
.moveToElementText(test
.firstChild
);
89 try { range
.select(); }
90 catch (error
) { ec
+= ' failed to select'; }
92 document
.execCommand('removeFormat', false, null);
95 addResult(document
.getElementById('exceptions'), elementName
, test
.innerHTML
, ec
);
99 if (!test
.firstChild
|| test
.firstChild
.nodeType
== 3 /*TextNode*/)
100 addResult(document
.getElementById('removed'), elementName
)
101 else if (contains(test
, instance
) && (instance
.innerHTML
== "" || instance
.innerHTML
== "hello=1;" || elementName
== "keygen"))
102 addResult(document
.getElementById('preserved'), elementName
);
104 addResult(document
.getElementById('exceptions'), elementName
, test
.innerHTML
);
106 document
.body
.removeChild(test
);