function testPositions(node) {
node.insertAdjacentHTML("beforeBegin", "\u003Cscript>ok(false, 'script should not have run');\u003C/script><i></i>");
is(node.previousSibling.localName, "i", "Should have had <i> as previous sibling");
node.insertAdjacentHTML("Afterbegin", "<b></b>\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.firstChild.localName, "b", "Should have had <b> as first child");
node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>ok(false, 'script should not have run');\u003C/script><u></u>");
is(node.lastChild.localName, "u", "Should have had <u> as last child");
node.insertAdjacentHTML("afterend", "<a></a>\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.nextSibling.localName, "a", "Should have had <a> as next sibling");
}
var content = document.getElementById("content");
testPositions(content); // without next sibling
testPositions(content); // test again when there's next sibling
try {
content.insertAdjacentHTML("bar", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "SyntaxError", "insertAdjacentHTML should throw SyntaxError");
is(e.code, 12, "insertAdjacentHTML should throw SYNTAX_ERR");
}
var parent = document.createElement("div"); var child = document.createElement("div");
try {
child.insertAdjacentHTML("Beforebegin", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "NoModificationAllowedError", "insertAdjacentHTML should throw NoModificationAllowedError");
is(e.code, 7, "insertAdjacentHTML should throw NO_MODIFICATION_ALLOWED_ERR");
}
try {
child.insertAdjacentHTML("AfterEnd", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "NoModificationAllowedError", "insertAdjacentHTML should throw NoModificationAllowedError");
is(e.code, 7, "insertAdjacentHTML should throw NO_MODIFICATION_ALLOWED_ERR");
}
testPositions(content2); // without next sibling
testPositions(content2); // test again when there's next sibling
is(events.length, 0, "Not all expected events fired.");
*/
// HTML only
document.body.insertAdjacentHTML("afterend", "<p>");
document.head.insertAdjacentHTML("beforebegin", "<p>");
is(document.getElementsByTagName("head").length, 1, "Should still have one head");
is(document.getElementsByTagName("body").length, 1, "Should still have one body");
</script>
</pre>
</body></html>
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.70 Sekunden
(vorverarbeitet am 2026-04-28)
¤
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.