Skip to content

Commit

Permalink
Merge pull request #74 from w3c/submission/Ms2ger/document.body
Browse files Browse the repository at this point in the history
Add a test for the document.body setter when there's no root element
  • Loading branch information
jgraham committed Apr 12, 2013
2 parents b682fe9 + 33fa97d commit 7334f2a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions html/dom/documents/dom-tree-accessors/document.body-setter-01.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<!DOCTYPE html>
<title>Setting document.body to incorrect values</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://www.whatwg.org/html5/#dom-document-body">
<link rel="help" href="http://www.whatwg.org/html/#dom-document-body">
<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_throws(new TypeError(), function() { document.body = "text" })
}, "Should throw a TypeError.");
assert_throws(new TypeError(), function() {
document.body = "text"
})
}, "Should throw a TypeError when trying to set document.body to a string.")
test(function() {
assert_throws("HIERARCHY_REQUEST_ERR", function() { document.body = document.createElement("div") })
}, "Should throw a HIERARCHY_REQUEST_ERR.");
assert_throws("HierarchyRequestError", function() {
document.body = document.createElement("div")
})
}, "Should throw a HierarchyRequestError when trying to set document.body to a div element.")
test(function() {
var doc = document.implementation.createHTMLDocument("")
doc.removeChild(doc.documentElement)
assert_throws("HierarchyRequestError", function() {
doc.body = document.createElement("body")
})
}, "Should throw a HierarchyRequestError when trying to set document.body when there's no root element.")
</script>

0 comments on commit 7334f2a

Please sign in to comment.