https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 1d3a2488d77445aded713d361d240612097874e6 authored by James Graham on 02 April 2014, 10:21:25 UTC
fixup! Use single_page branch of testharness.js
Tip revision: 1d3a248
Node-removeChild.html
<!DOCTYPE html>
<title>Node.removeChild</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="creators.js"></script>
<div id="log"></div>
<iframe src=about:blank></iframe>
<script>
var frameDoc = frames[0].document;
for (var p in creators) {
  var creator = creators[p];
  test(function() {
    var s = frameDoc[creator]("a")
    assert_equals(s.ownerDocument, frameDoc)
    assert_throws("NOT_FOUND_ERR", function() { document.body.removeChild(s) })
    assert_equals(s.ownerDocument, frameDoc)
  }, "Passing a detached " + p + " with a different node document to removeChild should not affect it.")
  test(function() {
    var s = frameDoc[creator]("b")
    frameDoc.body.appendChild(s)
    assert_equals(s.ownerDocument, frameDoc)
    assert_throws("NOT_FOUND_ERR", function() { document.body.removeChild(s) })
    assert_equals(s.ownerDocument, frameDoc)
  }, "Passing a non-detached " + p + " with a different node document to removeChild should not affect it.")
  test(function() {
    var s = frameDoc[creator]("test")
    frameDoc.body.appendChild(s)
    assert_equals(s.ownerDocument, frameDoc)
    assert_throws("NOT_FOUND_ERR", function() { s.removeChild(frameDoc) })
    assert_throws("NOT_FOUND_ERR", function() { s.removeChild(document) })
  }, "Calling removeChild on a " + p + " with no children should throw NOT_FOUND_ERR.")
}
test(function() {
  assert_throws(new TypeError(), function() { document.body.removeChild(null) })
  assert_throws(new TypeError(), function() { document.body.removeChild({'a':'b'}) })
}, "Passing a value that is not a Node reference to removeChild should throw TypeError.")
</script>
back to top