blob: c62979697fc574d1fad1ddaa1ec26fb7edf8149b [file] [log] [blame]
<!DOCTYPE html>
<html>
<style>
body {
height: 10000px;
}
dialog {
padding: 0;
margin: 0;
height: 50px;
width: 50px;
}
#console {
position: fixed;
}
</style>
<body>
<dialog id="top-dialog"></dialog>
<dialog id="first-middle-dialog"></dialog>
<dialog id="second-middle-dialog" style="left: 100px"></dialog>
<dialog id="bottom-dialog"></dialog>
</body>
<script src="../../../resources/js-test.js"></script>
<script>
debug('Test that multiple dialogs are centered properly. You should see four ' +
'boxes: one on the top row, two on the middle, and one on the bottom.');
function expectedTop(dialog) {
return window.scrollY + Math.floor((document.documentElement.clientHeight - dialog.offsetHeight) / 2);
}
function showAndTest(id) {
debug('showing ' + id);
dialog = document.getElementById(id);
dialog.showModal();
shouldBe('dialog.offsetTop', 'expectedTop(dialog)');
}
showAndTest('top-dialog');
window.scroll(0, 100);
showAndTest('first-middle-dialog');
showAndTest('second-middle-dialog');
window.scroll(0, 200);
showAndTest('bottom-dialog');
</script>
</html>