Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for the document.body setter when there's no root element #74

Merged
merged 1 commit into from
Apr 12, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>