| <!DOCTYPE html> |
| <html> |
| <body onload="runTest()"> |
| <p>This test only runs on DumpRenderTree, as it requires existence of window.internals and cross-domain resource access check disabled.</p> |
| <script src="../../resources/js-test.js"></script> |
| <script src="../../resources/gc.js"></script> |
| <script> |
| description("This test asserts that document doesn't leak when a selection is created inside the document."); |
| if (window.internals) |
| jsTestIsAsync = true; |
| |
| async function runTest() { |
| if (!window.internals) |
| return; |
| |
| try { |
| let message = await testDocumentIsNotLeaked(async documentCount => { |
| let frameIdentifiers = []; |
| for (var i = 0; i < documentCount; i++) { |
| let frame = document.body.appendChild(document.createElement("iframe")); |
| frame.src = 'data:text/html;charset=utf-8,<span id="t"></span>'; |
| await new Promise(resolve => { frame.onload = resolve; }); |
| frameIdentifiers.push(internals.documentIdentifier(frame.contentDocument)); |
| |
| let contentWindow = frame.contentWindow; |
| let element = contentWindow.document.getElementById("t"); |
| contentWindow.getSelection().setPosition(element, 0); |
| |
| frame.remove(); |
| } |
| return frameIdentifiers; |
| }); |
| testPassed(message); |
| } catch (error) { |
| testFailed(error.message); |
| } |
| finishJSTest(); |
| } |
| </script> |
| </body> |
| </html> |