OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>InputEvent: beforeinput shouldn't crash in removed iframe</title> | 4 <title>InputEvent: beforeinput shouldn't crash in removed iframe</title> |
5 <script src="../../../resources/testharness.js"></script> | 5 <script src="../../../resources/testharness.js"></script> |
6 <script src="../../../resources/testharnessreport.js"></script> | 6 <script src="../../../resources/testharnessreport.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 test(function() { | 10 test(function() { |
11 assert_not_equals(window.eventSender, undefined, 'This test requires eventSe
nder.'); | 11 assert_not_equals(window.eventSender, undefined, 'This test requires eventSe
nder.'); |
12 assert_not_equals(window.testRunner, undefined, 'This test requires testRunn
er.'); | 12 assert_not_equals(window.testRunner, undefined, 'This test requires testRunn
er.'); |
13 | 13 |
14 function testBeforeInputCrash(expectedBeforeInputCount, beforeInputTrigger,
comments) { | 14 function testBeforeInputCrash(expectedBeforeInputCount, beforeInputTrigger,
comments) { |
15 const iframe = document.createElement('iframe'); | 15 const iframe = document.createElement('iframe'); |
16 document.body.appendChild(iframe); | 16 document.body.appendChild(iframe); |
17 const childDocument = iframe.contentDocument; | 17 const childDocument = iframe.contentDocument; |
18 childDocument.body.innerHTML = '<p id="editable" contenteditable>Foo</p>
'; | 18 childDocument.body.innerHTML = '<p id="editable" contenteditable>Foo</p>
'; |
19 | 19 |
20 var actualBeforeInputCount = 0; | 20 var actualBeforeInputCount = 0; |
21 const editable = childDocument.getElementById('editable'); | 21 const editable = childDocument.getElementById('editable'); |
22 editable.addEventListener('beforeinput', event => { | 22 childDocument.addEventListener('beforeinput', event => { |
23 actualBeforeInputCount++; | 23 actualBeforeInputCount++; |
24 if (actualBeforeInputCount == expectedBeforeInputCount && iframe.par
entNode) | 24 if (actualBeforeInputCount == expectedBeforeInputCount && iframe.par
entNode) |
25 iframe.remove(); | 25 iframe.remove(); |
26 }); | 26 }); |
27 | 27 |
28 editable.focus(); | 28 editable.focus(); |
29 beforeInputTrigger(childDocument, editable); | 29 beforeInputTrigger(childDocument, editable); |
30 | 30 |
31 if (iframe.parentNode) | 31 if (iframe.parentNode) |
32 iframe.remove(); | 32 iframe.remove(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 | 109 |
110 // Test Drag&Drop. | 110 // Test Drag&Drop. |
111 t.step(() => testDragDropCrash('deleteByDrag', 'Testing deleteByDrag', | 111 t.step(() => testDragDropCrash('deleteByDrag', 'Testing deleteByDrag', |
112 () => testDragDropCrash('insertFromDrop', 'Testing insertFromDrop', | 112 () => testDragDropCrash('insertFromDrop', 'Testing insertFromDrop', |
113 () => t.done()))); | 113 () => t.done()))); |
114 }, 'Testing beforeinput for Drag&Drop in removed iframe'); | 114 }, 'Testing beforeinput for Drag&Drop in removed iframe'); |
115 </script> | 115 </script> |
116 </body> | 116 </body> |
117 </html> | 117 </html> |
OLD | NEW |