WPT
wpt / dom / nodes / Node-insertBefore.html
Spec: DOM ↗
Runs: Chrome 155.0.8042.0 (wpt@a1ecd0c09, 2026-09-04) | Firefox 157.0a1 (wpt@e23cee339, 2026-09-04) | Safari 251 preview (wpt@e7122b73f, 2026-09-04) | Ladybird 1.0-52f0f (wpt@0588f3896, 2026-09-04) | Servo Servo 0.6 (wpt@2c385f65e, 2026-09-04) | Blitz a50cb8971 (wpt@a95401e4e, 2026-09-03)
View on the Blitz WPT dashboard | Open test on wpt.live | wpt.fyi
| Chrome | Firefox | Safari | Ladybird | Servo | Blitz | |
|---|---|---|---|---|---|---|
| Total | 40/40 | 40/40 | 40/40 | 40/40 | 40/40 | NOT RUN |
| Subtest | Chrome | Firefox | Safari | Ladybird | Servo | Blitz |
|---|---|---|---|---|---|---|
| Should check the 'parent' type before checking whether 'child' is a child of 'parent' | PASS | PASS | PASS | PASS | PASS | — |
| Should check that 'node' is not an ancestor of 'parent' before checking whether 'child' is a child of 'parent' | PASS | PASS | PASS | PASS | PASS | — |
| Should check whether 'child' is a child of 'parent' before checking whether 'node' is of a type that can have a parent. | PASS | PASS | PASS | PASS | PASS | — |
| Should check whether 'child' is a child of 'parent' before checking whether 'node' is of a type that can have a parent of the type that 'parent' is. | PASS | PASS | PASS | PASS | PASS | — |
| Should check whether 'child' is a child of 'parent' before checking whether 'node' can be inserted into the document given the kids the document has right now. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a host-including inclusive ancestor of parent, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is not a DocumentFragment, DocumentType, Element, Text, ProcessingInstruction, or Comment node, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a Text node and parent is a document, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a doctype and parent is not a document, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a DocumentFragment with multiple elements and parent is a document, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a DocumentFragment with an element and parent is a document with another element, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is an Element and parent is a document with another element, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a doctype and parent is a document with another doctype, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| If node is a doctype and parent is a document with an element, then throw a HierarchyRequestError DOMException. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a non-Node first argument must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with second argument missing, or other than Node, null, or undefined, must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a non-Node first argument on a leaf node DocumentType must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore an a leaf node DocumentType must throw HIERARCHY_REQUEST_ERR. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a non-Node first argument on a leaf node Text must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore an a leaf node Text must throw HIERARCHY_REQUEST_ERR. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a non-Node first argument on a leaf node Comment must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore an a leaf node Comment must throw HIERARCHY_REQUEST_ERR. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a non-Node first argument on a leaf node ProcessingInstruction must throw TypeError. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore an a leaf node ProcessingInstruction must throw HIERARCHY_REQUEST_ERR. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with an inclusive ancestor of the context object must throw HIERARCHY_REQUEST_ERR. | PASS | PASS | PASS | PASS | PASS | — |
| Calling insertBefore with a reference child whose parent is not the context node must throw a NotFoundError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a document or text node should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a DocumentFragment that contains a text node or too many elements should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a DocumentFragment with an element if there already is an element child should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document and a doctype is following the reference child, inserting a DocumentFragment with an element should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a DocumentFragment with an element before the doctype should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting an element if there already is an element child should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting an element before the doctype should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document and a doctype is following the reference child, inserting an element should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a doctype if there already is a doctype child should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document, inserting a doctype after the document element should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a document with and element child, appending a doctype should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is a DocumentFragment, inserting a document or a doctype should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| If the context node is an element, inserting a document or a doctype should throw a HierarchyRequestError. | PASS | PASS | PASS | PASS | PASS | — |
| Inserting a node before itself should not move the node | PASS | PASS | PASS | PASS | PASS | — |