writer-from-detached-iframe.tentative.https.window.js (2327B)
1 // META: title=Writer Detached Iframe 2 // META: script=/resources/testdriver.js 3 // META: script=../resources/util.js 4 // META: timeout=long 5 6 'use strict'; 7 8 promise_test(async (t) => { 9 const iframe = document.body.appendChild(document.createElement('iframe')); 10 await test_driver.bless('Writer create()', null, iframe.contentWindow); 11 iframe.contentWindow.Writer.create(); 12 iframe.remove(); 13 }, 'Detaching iframe during Writer.create() should not leak memory'); 14 15 promise_test(async (t) => { 16 const iframe = document.body.appendChild(document.createElement('iframe')); 17 await test_driver.bless('Writer create()', null, iframe.contentWindow); 18 const iframeWindow = iframe.contentWindow; 19 const iframeDOMException = iframeWindow.DOMException; 20 const iframeWriter = iframeWindow.Writer; 21 iframe.remove(); 22 23 await promise_rejects_dom( 24 t, 'InvalidStateError', iframeDOMException, iframeWriter.create()); 25 }, 'Writer.create() fails on a detached iframe'); 26 27 promise_test(async (t) => { 28 const iframe = document.body.appendChild(document.createElement('iframe')); 29 await test_driver.bless('Writer create()', null, iframe.contentWindow); 30 const iframeDOMException = iframe.contentWindow.DOMException; 31 const writer = await iframe.contentWindow.Writer.create(); 32 iframe.remove(); 33 34 await promise_rejects_dom( 35 t, 'InvalidStateError', iframeDOMException, writer.write(kTestPrompt)); 36 }, 'Writer.write() fails on a detached iframe'); 37 38 promise_test(async (t) => { 39 const iframe = document.body.appendChild(document.createElement('iframe')); 40 await test_driver.bless('Writer create()', null, iframe.contentWindow); 41 const iframeWindow = iframe.contentWindow; 42 const iframeDOMException = iframeWindow.DOMException; 43 const writer = await iframeWindow.Writer.create(); 44 iframe.remove(); 45 46 assert_throws_dom( 47 'InvalidStateError', 48 iframeDOMException, () => writer.writeStreaming(kTestPrompt)); 49 }, 'Writer.writeStreaming() fails on a detached iframe'); 50 51 promise_test(async (t) => { 52 const iframe = document.body.appendChild(document.createElement('iframe')); 53 await test_driver.bless('Writer create()', null, iframe.contentWindow); 54 const writer = await iframe.contentWindow.Writer.create(); 55 writer.write(kTestPrompt); 56 iframe.remove(); 57 }, 'Detaching iframe during Writer.write() should not leak memory');