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