| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <style> | 3 <style> |
| 4 dialog { | 4 dialog { |
| 5 /* Don't needlessly span the whole screen. */ | 5 /* Don't needlessly span the whole screen. */ |
| 6 width: 50px; | 6 width: 50px; |
| 7 } | 7 } |
| 8 </style> | 8 </style> |
| 9 <body> | 9 <body> |
| 10 <script src="../../js/resources/js-test-pre.js"></script> | 10 <script src="../../../resources/js-test.js"></script> |
| 11 <button>Click me</button> | 11 <button>Click me</button> |
| 12 <div id="div">Click me too</div> | 12 <div id="div">Click me too</div> |
| 13 <dialog></dialog> | 13 <dialog></dialog> |
| 14 <script> | 14 <script> |
| 15 description('Test that inert nodes still get programmatic click events'); | 15 description('Test that inert nodes still get programmatic click events'); |
| 16 dialog = document.querySelector('dialog'); | 16 dialog = document.querySelector('dialog'); |
| 17 dialog.showModal(); | 17 dialog.showModal(); |
| 18 | 18 |
| 19 button = document.querySelector('button'); | 19 button = document.querySelector('button'); |
| 20 div = document.getElementById('div'); | 20 div = document.getElementById('div'); |
| 21 clicked = null; | 21 clicked = null; |
| 22 | 22 |
| 23 [button, div].forEach(function(element) { | 23 [button, div].forEach(function(element) { |
| 24 element.addEventListener('click', function(e) { clicked = element; }); | 24 element.addEventListener('click', function(e) { clicked = element; }); |
| 25 expectedElement = element; | 25 expectedElement = element; |
| 26 | 26 |
| 27 clicked = null; | 27 clicked = null; |
| 28 debug('Calling click() on ' + element.tagName); | 28 debug('Calling click() on ' + element.tagName); |
| 29 element.click(); | 29 element.click(); |
| 30 shouldBe('clicked', 'expectedElement'); | 30 shouldBe('clicked', 'expectedElement'); |
| 31 | 31 |
| 32 clicked = null; | 32 clicked = null; |
| 33 debug('Calling dispatchEvent() on ' + element.tagName); | 33 debug('Calling dispatchEvent() on ' + element.tagName); |
| 34 element.dispatchEvent(new Event('click')); | 34 element.dispatchEvent(new Event('click')); |
| 35 shouldBe('clicked', 'expectedElement'); | 35 shouldBe('clicked', 'expectedElement'); |
| 36 }); | 36 }); |
| 37 </script> | 37 </script> |
| 38 </body> | 38 </body> |
| 39 </html> | 39 </html> |
| OLD | NEW |