OLD | NEW |
1 <html> | 1 <html> |
2 <head> | |
3 <script src="../../fast/js/resources/js-test-pre.js"></script> | |
4 </head> | |
5 <body> | 2 <body> |
6 <span>This test only runs on DumpRenderTree, as it requires existence of win
dow.internals and cross-domain resource access check disabled.</span> | 3 <script id='targetHTML' type='text/html'> |
7 <iframe id="f" src='about:blank'></iframe> | 4 <span id='t'></span> |
| 5 </script> |
| 6 <script id='targetJS' type='text/html'> |
| 7 var element = document.getElementById("t"); |
| 8 window.getSelection().setPosition(element, 0); |
| 9 </script> |
| 10 |
| 11 <script src="../../fast/js/resources/js-test-pre.js"></script> |
| 12 <script src="../../fast/dom/resources/leak-check.js"></script> |
8 <script> | 13 <script> |
9 description("This test asserts that document doesn't leak when a selecti
on is created inside the document."); | 14 description("This test asserts that document doesn't leak when a selecti
on is created inside the document."); |
10 | 15 |
11 jsTestIsAsync = true; | 16 var target = grabScriptText('targetHTML') + |
12 if (!window.internals) | 17 '<script>'+grabScriptText('targetJS')+'<'+'/script>'; |
13 finishJSTest(); | 18 var tolerance = {'numberOfLiveDocuments': 0}; |
14 | 19 |
15 function countNumberOfLiveDocuments() { | 20 doLeakTest(htmlToUrl(target), tolerance); |
16 gc(); | |
17 return window.internals.numberOfLiveDocuments(); | |
18 } | |
19 | |
20 var numberOfDocumentsBefore = countNumberOfLiveDocuments(); | |
21 var numberOfDocumentsAfter = 0; | |
22 | |
23 var frame = document.getElementById('f'); | |
24 frame.onload = function() { | |
25 if (frame.src === 'about:blank') return true; | |
26 | |
27 // document loaded... | |
28 | |
29 // create a selection inside iframe | |
30 (function() { | |
31 var contentWindow = frame.contentWindow; | |
32 var element = contentWindow.document.getElementById("t"); | |
33 contentWindow.getSelection().setPosition(element, 0); | |
34 })(); | |
35 | |
36 frame.onload = function() { | |
37 // document unloaded... | |
38 | |
39 numberOfDocumentsAfter = countNumberOfLiveDocuments(); | |
40 shouldBe("numberOfDocumentsAfter", "numberOfDocumentsBefore"); | |
41 finishJSTest(); | |
42 } | |
43 frame.src = 'about:blank'; | |
44 } | |
45 frame.src='data:text/html;charset=utf-8,<span id="t"></span>'; | |
46 </script> | 21 </script> |
47 <script src="../../fast/js/resources/js-test-post.js"></script> | 22 <script src="../../fast/js/resources/js-test-post.js"></script> |
48 </body> | 23 </body> |
49 </html> | 24 </html> |
OLD | NEW |