This tests that various combinations of replaceChild on the document works as specified.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


replacing element with element
PASS doc.replaceChild(newChild, doc.documentElement) did not throw exception.
<!DOCTYPE html><div/>

replacing element with element in fragment
PASS doc.replaceChild(fragment, doc.documentElement); did not throw exception.
<!DOCTYPE html><div/>

replacing element with multiple elements in fragment
PASS doc.replaceChild(fragment, doc.documentElement); threw exception Error: HierarchyRequestError: DOM Exception 3.
<!DOCTYPE html><body/>

replacing element with doctype
PASS doc.replaceChild(newChild, doc.documentElement) did not throw exception.
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

replacing element with doctype when a doctype already exists
PASS doc.replaceChild(newChild, doc.documentElement) threw exception Error: HierarchyRequestError: DOM Exception 3.
<!DOCTYPE html><body/>

replacing doctype with doctype
PASS doc.replaceChild(newChild, doc.doctype) did not throw exception.
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><body/>

replacing doctype with element
PASS doc.replaceChild(newChild, doc.doctype) did not throw exception.
<bar/>

replacing element with doctype when an element already exists
PASS doc.replaceChild(newChild, doc.documentElement) threw exception Error: HierarchyRequestError: DOM Exception 3.
<!DOCTYPE html><body/>

PASS successfullyParsed is true

TEST COMPLETE

