tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / parser / script-tests / fragment-parser.js
1 description('Test that fragment parsing does not affect the host document.');
2
3 function parse(string, removeDocumentElement) {
4     var iframe = document.createElement("iframe");
5     document.body.appendChild(iframe);
6     var doc = iframe.contentDocument;
7     doc.documentElement.removeChild(doc.documentElement.firstChild);
8     if (removeDocumentElement)
9         doc.removeChild(doc.documentElement);
10
11     var div = doc.createDocumentFragment().appendChild(doc.createElement("div"));
12     div.innerHTML = string;
13     document.body.removeChild(iframe);
14     return [div.innerHTML, doc.documentElement ? doc.documentElement.outerHTML : "no document element"];
15 }
16
17 shouldBe("parse('<span><body bgcolor=red>')", "['<span></span>','<html><body></body></html>']");
18 shouldBe("parse('<span><html bgcolor=red>')", "['<span></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>']");
21 shouldBe("parse('<html><script>')", "['<script></script>','<html><body></body></html>']");
22 shouldBe("parse('<html><style>')", "['<style></style>','<html><body></body></html>']");
23 shouldBe("parse('<html><meta>')", "['<meta>','<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>']");
26 shouldBe("parse('<html><embed>')", "['<embed>','<html><body></body></html>']");
27
28 shouldBe("parse('<html><title>')", "['<title></title>','<html><body></body></html>']");
29 shouldBe("parse('<html><isindex>')", "['<form><hr><label>This is a searchable index. Enter search keywords: <input name=\"isindex\"></label><hr></form>','<html><body></body></html>']");
30 shouldBe("parse('<html><base>')", "['','<html><body></body></html>']");
31 shouldBe("parse('<html><div>')", "['<div></div>','<html><body></body></html>']");
32 shouldBe("parse('<frameset>')", "['','<html><body></body></html>']");
33 shouldBe("parse('<html>x', true)", "['x','no document element']");