/
document_body.html
66 lines (55 loc) · 3.51 KB
/
document_body.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_not_equals(document.body, null, "test1-0, existing document's body");
assert_true(document.body instanceof HTMLBodyElement, "test1-1, exising document's body: should be HTMLBodyElement");
assert_equals(document.body && document.body.tagName, "BODY", "test1-2, existing document's body");
}, "existing document's body");
test(function() {
var new_body = document.createElement("body");
assert_not_equals(new_body, null, "test2-0, replace document's body with new body");
document.body = new_body;
assert_equals(new_body, document.body, "test2-1, replace document's body with new body");
}, "replace document's body with new body");
test(function() {
var new_frameset = document.createElement("frameset");
assert_not_equals(new_frameset, null, "test2-0, replace document's body with new frameset");
document.body = new_frameset;
assert_equals(new_frameset, document.body, "test2-1, replace document's body with new frameset");
}, "replace document's body with new frameset");
test(function() {
var new_document = new Document();
new_document.appendChild(new_document.createElement("html"));
var new_div = new_document.createElement("div");
assert_not_equals(new_div, null, "test4-0, append an invalid element to a new document");
assert_throws(null, function() {
new_document.body = new_div;
});
assert_equals(new_document.body, null, "test4-1, append an invalid element to a new document");
}, "append an invalid element to a new document");
test(function() {
var new_document = document.implementation.createHTMLDocument();
var new_body = new_document.createElement("body");
assert_not_equals(new_body, null, "test5-0, append body to a new document");
assert_true(new_body instanceof HTMLBodyElement, "test5-1, append body to a new document: should be HTMLBodyElement");
assert_equals(new_body && new_body.tagName, "BODY", "test5-2, append body to a new document");
new_document.body = new_body;
assert_equals(new_document.body, new_body, "test5-3, append body to a new document");
}, "append body to a new document");
test(function() {
var new_document = document.implementation.createHTMLDocument();
var new_frameset = new_document.createElement("frameset");
assert_not_equals(new_frameset, null, "test6-0, append frameset to a new document");
assert_true(new_frameset instanceof HTMLFrameSetElement, "test6-1, append frameset to a new document: should be HTMLFrameSetElement");
assert_equals(new_frameset && new_frameset.tagName, "FRAMESET", "test6-2, append frameset to a new document");
new_document.body = new_frameset;
assert_equals(new_document.body, new_frameset, "test6-3, append frameset to a new document");
}, "append frameset to a new document");
</script>
</body>
</html>