OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <style> | |
4 body { | |
5 height: 10000px; | |
6 } | |
7 | |
8 dialog { | |
9 padding: 0; | |
10 margin: 0; | |
11 height: 50px; | |
12 width: 50px; | |
13 } | |
14 | |
15 #console { | |
16 position: fixed; | |
17 } | |
18 </style> | |
19 <body> | |
20 <dialog id="top-dialog"></dialog> | |
21 <dialog id="first-middle-dialog"></dialog> | |
22 <dialog id="second-middle-dialog" style="left: 100px"></dialog> | |
23 <dialog id="bottom-dialog"></dialog> | |
24 </body> | |
25 <script src="../../../resources/js-test.js"></script> | |
26 <script> | |
27 debug('Test that multiple dialogs are centered properly. You should see four ' + | |
28 'boxes: one on the top row, two on the middle, and one on the bottom.'); | |
29 | |
30 function expectedTop(dialog) { | |
31 return window.scrollY + Math.floor((document.documentElement.clientHeight -
dialog.offsetHeight) / 2); | |
32 } | |
33 | |
34 function showAndTest(id) { | |
35 debug('showing ' + id); | |
36 dialog = document.getElementById(id); | |
37 dialog.showModal(); | |
38 shouldBe('dialog.offsetTop', 'expectedTop(dialog)'); | |
39 } | |
40 | |
41 showAndTest('top-dialog'); | |
42 | |
43 window.scroll(0, 100); | |
44 showAndTest('first-middle-dialog'); | |
45 showAndTest('second-middle-dialog'); | |
46 | |
47 window.scroll(0, 200); | |
48 showAndTest('bottom-dialog'); | |
49 </script> | |
50 </html> | |
OLD | NEW |