Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/dialog-close-event.html

Issue 2375413002: Remove timing dependency to document onload in dialog-close-event.html (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check close event is not called sync Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/dialog-close-event-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/dialog-close-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698