OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <style> | |
5 body { | |
6 margin: 0; | |
7 } | |
8 | |
9 dialog { | |
10 padding : 0; | |
11 } | |
12 | |
13 #console { | |
14 position: fixed; | |
15 } | |
16 </style> | |
17 <script src="../../../resources/js-test.js"></script> | |
18 </head> | |
19 <body style="height: 10000px; width: 10000px"> | |
20 <div style="position: absolute; top: 5000px; left: 5000px; width: 20px;"> | |
21 <dialog id="dialog" style="top: 1200px; left: 1200px; right: auto; height: 1
00px; width: 50%; background-color: yellow"> | |
22 </dialog> | |
23 </div> | |
24 <script> | |
25 debug("This tests that a modal dialog's containing block is the initial containi
ng block."); | |
26 debug('The dialog should be onscreen with a width of 50% of the viewport. It is
the child of a ' + | |
27 'narrow element positioned off screen, but its containing block is the ini
tial containing ' + | |
28 'block, so its position and percent lengths are relative to that.'); | |
29 | |
30 function checkPosition(dialog) { | |
31 shouldBe('dialog.offsetParent', 'null'); | |
32 shouldBe('dialog.offsetTop', '1200'); | |
33 shouldBe('dialog.offsetLeft', '1200'); | |
34 // Since dialog's 'width' is '50%', the expected width is half of the | |
35 // viewport width, but viewport width may be odd. It seems Blink rounds up f
or | |
36 // percentage lengths, so use Math.ceil here. | |
37 expectedWidth = Math.ceil(document.documentElement.clientWidth / 2); | |
38 shouldBe('dialog.clientWidth', 'expectedWidth'); | |
39 } | |
40 | |
41 window.scroll(1000, 1000); | |
42 dialog = document.getElementById('dialog'); | |
43 dialog.showModal(); | |
44 checkPosition(dialog); | |
45 dialog.close(); | |
46 </script> | |
47 </body> | |
48 </html> | |
OLD | NEW |