| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <dialog></dialog> | |
| 8 <script> | |
| 9 description("Test that dialog receives a close event upon closing."); | |
| 10 jsTestIsAsync = true; | |
| 11 | |
| 12 document.addEventListener('close', function(event) { | |
| 13 testFailed("The 'close' event unexpectedly bubbled."); | |
| 14 }); | |
| 15 | |
| 16 closedCount = 0; | |
| 17 dialog = document.querySelector('dialog'); | |
| 18 dialog.addEventListener('close', function(event) { | |
| 19 closedCount++; | |
| 20 selfDialog = this; | |
| 21 shouldBe('selfDialog', 'dialog'); | |
| 22 shouldBeFalse('dialog.open'); | |
| 23 shouldBeFalse('event.cancelable'); | |
| 24 event.preventDefault(); | |
| 25 | |
| 26 if (closedCount == 1) { | |
| 27 dialog.show(); | |
| 28 dialog.close(); | |
| 29 // dialog's close event handler shouldn't be called synchronously. | |
| 30 shouldBe('closedCount', '1'); | |
| 31 } else if (closedCount == 2) { | |
| 32 finishJSTest(); | |
| 33 } | |
| 34 }); | |
| 35 | |
| 36 dialog.show(); | |
| 37 dialog.close(); | |
| 38 | |
| 39 // Verify that preventDefault() didn't cancel closing. | |
| 40 shouldBeFalse('dialog.open'); | |
| 41 | |
| 42 // dialog's close event handler shouldn't be called synchronously. | |
| 43 shouldBe('closedCount', '0'); | |
| 44 </script> | |
| 45 </body> | |
| 46 </html> | |
| OLD | NEW |