| OLD | NEW |
| 1 description('Test that fragment parsing does not affect the host document.'); | 1 description('Test that fragment parsing does not affect the host document.'); |
| 2 | 2 |
| 3 function parse(string, removeDocumentElement) { | 3 function parse(string, removeDocumentElement) { |
| 4 var iframe = document.createElement("iframe"); | 4 var iframe = document.createElement("iframe"); |
| 5 document.body.appendChild(iframe); | 5 document.body.appendChild(iframe); |
| 6 var doc = iframe.contentDocument; | 6 var doc = iframe.contentDocument; |
| 7 doc.documentElement.removeChild(doc.documentElement.firstChild); | 7 doc.documentElement.removeChild(doc.documentElement.firstChild); |
| 8 if (removeDocumentElement) | 8 if (removeDocumentElement) |
| 9 doc.removeChild(doc.documentElement); | 9 doc.removeChild(doc.documentElement); |
| 10 | 10 |
| 11 var div = doc.createDocumentFragment().appendChild(doc.createElement("div"))
; | 11 var div = doc.createDocumentFragment().appendChild(doc.createElement("div"))
; |
| 12 div.innerHTML = string; | 12 div.innerHTML = string; |
| 13 document.body.removeChild(iframe); | 13 document.body.removeChild(iframe); |
| 14 return [div.innerHTML, doc.documentElement ? doc.documentElement.outerHTML :
"no document element"]; | 14 return [div.innerHTML, doc.documentElement ? doc.documentElement.outerHTML :
"no document element"]; |
| 15 } | 15 } |
| 16 | 16 |
| 17 shouldBe("parse('<span><body bgcolor=red>')", "['<span></span>','<html><body></b
ody></html>']"); | 17 shouldBe("parse('<span><body bgcolor=red>')", "['<span></span>','<html><body></b
ody></html>']"); |
| 18 shouldBe("parse('<span><html bgcolor=red>')", "['<span></span>','<html><body></b
ody></html>']"); | 18 shouldBe("parse('<span><html bgcolor=red>')", "['<span></span>','<html><body></b
ody></html>']"); |
| 19 shouldBe("parse('<span><meta>')", "['<span><meta></span>','<html><body></body></
html>']"); | 19 shouldBe("parse('<span><meta>')", "['<span><meta></span>','<html><body></body></
html>']"); |
| 20 shouldBe("parse('<span><base>')", "['<span><base></span>','<html><body></body></
html>']"); | 20 shouldBe("parse('<span><base>')", "['<span><base></span>','<html><body></body></
html>']"); |
| 21 shouldBe("parse('<html><script>')", "['<script></script>','<html><body></body></
html>']"); | 21 shouldBe("parse('<html><script>')", "['<script></script>','<html><body></body></
html>']"); |
| 22 shouldBe("parse('<html><style>')", "['<style></style>','<html><body></body></htm
l>']"); | 22 shouldBe("parse('<html><style>')", "['<style></style>','<html><body></body></htm
l>']"); |
| 23 shouldBe("parse('<html><meta>')", "['<meta>','<html><body></body></html>']"); | 23 shouldBe("parse('<html><meta>')", "['<meta>','<html><body></body></html>']"); |
| 24 shouldBe("parse('<html><link>')", "['<link>','<html><body></body></html>']"); | 24 shouldBe("parse('<html><link>')", "['<link>','<html><body></body></html>']"); |
| 25 shouldBe("parse('<html><object>')", "['<object></object>','<html><body></body></
html>']"); | 25 shouldBe("parse('<html><object>')", "['<object></object>','<html><body></body></
html>']"); |
| 26 shouldBe("parse('<html><embed>')", "['<embed>','<html><body></body></html>']"); | 26 shouldBe("parse('<html><embed>')", "['<embed>','<html><body></body></html>']"); |
| 27 | 27 |
| 28 shouldBe("parse('<html><title>')", "['<title></title>','<html><body></body></htm
l>']"); | 28 shouldBe("parse('<html><title>')", "['<title></title>','<html><body></body></htm
l>']"); |
| 29 shouldBe("parse('<html><isindex>')", "['<form><hr><label>This is a searchable in
dex. Enter search keywords: <input name=\"isindex\"></label><hr></form>','<html>
<body></body></html>']"); | 29 shouldBe("parse('<html><isindex>')", "['<isindex></isindex>','<html><body></body
></html>']"); |
| 30 shouldBe("parse('<html><base>')", "['','<html><body></body></html>']"); | 30 shouldBe("parse('<html><base>')", "['','<html><body></body></html>']"); |
| 31 shouldBe("parse('<html><div>')", "['<div></div>','<html><body></body></html>']")
; | 31 shouldBe("parse('<html><div>')", "['<div></div>','<html><body></body></html>']")
; |
| 32 shouldBe("parse('<frameset>')", "['','<html><body></body></html>']"); | 32 shouldBe("parse('<frameset>')", "['','<html><body></body></html>']"); |
| 33 shouldBe("parse('<html>x', true)", "['x','no document element']"); | 33 shouldBe("parse('<html>x', true)", "['x','no document element']"); |
| OLD | NEW |