function newRenderedHTMLDocument(context) { var frame = newIFrame(context); var d = frame.contentWindow.document; return d;
}
function newContext() { return {
iframes : []
};
}
function cleanContext(context) {
context.iframes.forEach(function(e) {
e.parentNode.removeChild(e);
});
}
// run given test function in context // the context is cleaned up after test completes. function inContext(f) { returnfunction() { var context = newContext(); try {
f(context);
} finally {
cleanContext(context);
}
};
}
// new context and iframe are created and url (if supplied) is asigned to // iframe.src // function f is bound to the iframe onload event or executed directly after // iframe creation // the context is passed to function as argument function testInIFrame(url, f, testName, testProps) { if (url) { var t = async_test(testName);
t.step(function() { var context = newContext(); var iframe = newIFrame(context, url);
iframe.onload = t.step_func(function() { try {
f(context);
t.done();
} finally {
cleanContext(context);
}
});
});
} else {
test(inContext(function(context) {
newRenderedHTMLDocument(context);
f(context);
}), testName);
}
}
function assert_nodelist_contents_equal_noorder(actual, expected, message) {
assert_equals(actual.length, expected.length, message); var used = []; for ( var i = 0; i < expected.length; i++) {
used.push(false);
} for (i = 0; i < expected.length; i++) { var found = false; for ( var j = 0; j < actual.length; j++) { if (used[j] == false && expected[i] == actual[j]) {
used[j] = true;
found = true; break;
}
} if (!found) {
assert_unreached(message + ". Fail reason: element not found: "
+ expected[i]);
}
}
}
function isVoidElement(elementName) { return HTML5_VOID_ELEMENTS.indexOf(elementName) >= 0;
}
function checkTemplateContent(d, obj, html, id, nodeName) {
obj.innerHTML = '' + html + '';
var t = d.querySelector('#tmpl');
if (id != null) {
assert_equals(t.content.childNodes.length, 1, 'Element ' + nodeName
+ ' should present among template nodes');
assert_equals(t.content.firstChild.id, id, 'Wrong element ID');
} if (nodeName != null) {
assert_equals(t.content.firstChild.nodeName, nodeName.toUpperCase(), 'Wrong node name');
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.