mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Merge existing wpt Document::body tests.
This commit is contained in:
parent
78ae9a5da0
commit
cfe2c6b504
3 changed files with 34 additions and 32 deletions
|
@ -118,4 +118,26 @@ test(function() {
|
|||
doc.appendChild(doc.createElementNS("http://example.org/test", "frameset"));
|
||||
assert_equals(doc.body, null);
|
||||
}, "Non-HTML frameset as the root node");
|
||||
|
||||
|
||||
var originalBody = document.body;
|
||||
test(function() {
|
||||
assert_throws(new TypeError(), function() {
|
||||
document.body = "text"
|
||||
})
|
||||
assert_equals(document.body, originalBody);
|
||||
}, "Setting document.body to a string.")
|
||||
test(function() {
|
||||
assert_throws("HierarchyRequestError", function() {
|
||||
document.body = document.createElement("div")
|
||||
})
|
||||
assert_equals(document.body, originalBody);
|
||||
}, "Setting document.body to a div element.")
|
||||
test(function() {
|
||||
var doc = createDocument();
|
||||
assert_throws("HierarchyRequestError", function() {
|
||||
doc.body = doc.createElement("body")
|
||||
})
|
||||
assert_equals(doc.body, null);
|
||||
}, "Setting document.body when there's no root element.")
|
||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Setting document.body to incorrect values</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-body">
|
||||
<link rel="help" href="https://heycam.github.io/webidl/#es-interface">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var originalBody = document.body;
|
||||
test(function() {
|
||||
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("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.")
|
||||
test(function() {
|
||||
assert_equals(document.body, originalBody);
|
||||
}, "document.body has not changed")
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue