| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
| 4 | 4 |
| 5 <script> | 5 <script> |
| 6 description('Tests getting and assigning values to document.body'); | 6 description('Tests getting and assigning values to document.body'); |
| 7 | 7 |
| 8 onload = function() { | 8 onload = function() { |
| 9 frame = document.createElement('iframe'); | 9 frame = document.createElement('iframe'); |
| 10 document.body.appendChild(frame); | 10 document.body.appendChild(frame); |
| 11 | 11 |
| 12 shouldThrow('frame.contentDocument.body = document.createElement("div")', "
'HierarchyRequestError: A Node was inserted somewhere it doesn\\'t belong.'"); | 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("framese
t")'); | 13 shouldNotThrow('frame.contentDocument.body = document.createElement("framese
t")'); |
| 14 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2'); | 14 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2'); |
| 15 shouldNotThrow('frame.contentDocument.body = document.createElement("body")'
); | 15 shouldNotThrow('frame.contentDocument.body = document.createElement("body")'
); |
| 16 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2'); | 16 shouldBe('frame.contentDocument.documentElement.childNodes.length', '2'); |
| 17 | 17 |
| 18 observer = new MutationObserver(function(records) { }); | 18 observer = new MutationObserver(function(records) { }); |
| 19 observer.observe(frame.contentDocument, { subtree: true, childList: true }); | 19 observer.observe(frame.contentDocument, { subtree: true, childList: true }); |
| 20 // If the nodes are the same this should be a noop. | 20 // If the nodes are the same this should be a noop. |
| 21 frame.contentDocument.body = frame.contentDocument.body; | 21 frame.contentDocument.body = frame.contentDocument.body; |
| 22 shouldBe('observer.takeRecords().length', '0'); | 22 shouldBe('observer.takeRecords().length', '0'); |
| 23 | 23 |
| 24 // WebKit calls importNode() and appends a clone instead of the element you
wanted. | 24 // WebKit calls importNode() and appends a clone instead of the element you
wanted. |
| 25 newBody = document.createElement("body"); | 25 newBody = document.createElement("body"); |
| 26 frame.contentDocument.body = newBody; | 26 frame.contentDocument.body = newBody; |
| 27 shouldBe('frame.contentDocument.body', 'newBody'); | 27 shouldBe('frame.contentDocument.body', 'newBody'); |
| 28 | 28 |
| 29 newBody = frame.contentDocument.createElement('body'); | 29 newBody = frame.contentDocument.createElement('body'); |
| 30 frame.contentDocument.body = newBody; | 30 frame.contentDocument.body = newBody; |
| 31 shouldBe("frame.contentDocument.body", "newBody") | 31 shouldBe("frame.contentDocument.body", "newBody") |
| 32 | 32 |
| 33 var html = frame.contentDocument.documentElement; | 33 var html = frame.contentDocument.documentElement; |
| 34 html.appendChild(document.createElement('body')); | 34 html.appendChild(document.createElement('body')); |
| 35 html.appendChild(document.createElement('frameset')); | 35 html.appendChild(document.createElement('frameset')); |
| 36 shouldBeEqualToString('frame.contentDocument.body.tagName', 'BODY'); | 36 shouldBeEqualToString('frame.contentDocument.body.tagName', 'BODY'); |
| 37 }; | 37 }; |
| 38 </script> | 38 </script> |
| 39 | 39 |
| OLD | NEW |