3 <script src=
"../../resources/js-test.js"></script>
6 description('Tests getting and assigning values to document.body');
9 frame
= document
.createElement('iframe');
10 document
.body
.appendChild(frame
);
12 shouldThrow('frame.contentDocument.body = document.createElement("div")', '"HierarchyRequestError: Failed to set the \'body\' property on \'Document\': The new body element is of type \'DIV\'. It must be either a \'BODY\' or \'FRAMESET\' element."');
13 shouldNotThrow('frame.contentDocument.body = document.createElement("frameset")');
14 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2');
15 shouldNotThrow('frame.contentDocument.body = document.createElement("body")');
16 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2');
18 observer
= new MutationObserver(function(records
) { });
19 observer
.observe(frame
.contentDocument
, { subtree
: true, childList
: true });
20 // If the nodes are the same this should be a noop.
21 frame
.contentDocument
.body
= frame
.contentDocument
.body
;
22 shouldBe('observer.takeRecords().length', '0');
24 // WebKit calls importNode() and appends a clone instead of the element you wanted.
25 newBody
= document
.createElement("body");
26 frame
.contentDocument
.body
= newBody
;
27 shouldBe('frame.contentDocument.body', 'newBody');
29 newBody
= frame
.contentDocument
.createElement('body');
30 frame
.contentDocument
.body
= newBody
;
31 shouldBe("frame.contentDocument.body", "newBody")
33 var html
= frame
.contentDocument
.documentElement
;
34 html
.appendChild(document
.createElement('body'));
35 html
.appendChild(document
.createElement('frameset'));
36 shouldBeEqualToString('frame.contentDocument.body.tagName', 'BODY');