Bug 936994 - Update html5lib-tests to latest version as of Oct 8, 2013. r=hsivonen

This commit is contained in:
William Chen
2013-11-10 22:02:21 -08:00
parent e40efa2da2
commit 884e71b64e
49 changed files with 4333 additions and 1324 deletions

View File

@@ -104,6 +104,18 @@ function docToTestOutput(doc) {
return addLevels(walker, "", "| ").slice(0,-1); // remove the last newline
}
/**
* Creates a walker for a fragment that skips over the root node.
*
* @param an element
*/
function createFragmentWalker(elt) {
return elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
function (node) {
return elt == node ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
});
}
/**
* Transforms the descendants of an element to a string matching the format
* in the test cases.
@@ -111,10 +123,7 @@ function docToTestOutput(doc) {
* @param an element
*/
function fragmentToTestOutput(elt) {
var walker = elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
function (node) { return elt == node ?
NodeFilter.FILTER_SKIP :
NodeFilter.FILTER_ACCEPT; });
var walker = createFragmentWalker(elt);
return addLevels(walker, "", "| ").slice(0,-1); // remove the last newline
}
@@ -184,6 +193,15 @@ function addLevels(walker, buf, indent) {
break;
}
buf += "\n";
// In the case of template elements, children do not get inserted as
// children of the template element, instead they are inserted
// as children of the template content (which is a document fragment).
if (walker.currentNode instanceof HTMLTemplateElement) {
buf += indent + " content\n";
// Walk through the template content.
var templateWalker = createFragmentWalker(walker.currentNode.content);
buf = addLevels(templateWalker, buf, indent + " ");
}
buf = addLevels(walker, buf, indent + " ");
} while(walker.nextSibling());
walker.parentNode();