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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout.html

Issue 2671603003: Move DIALOG element tests to html/dialog/. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <link href="resources/dialog-layout.css" rel="stylesheet">
3 <style>
4 dialog {
5 position: fixed;
6 }
7 </style>
8 <script src="../../../resources/js-test.js"></script>
9 <dialog id="dialog">It is my dialog.</dialog>
10 <div id="absolute-div">
11 <div id="relative-div"></div>
12 </div>
13 <script>
14 description('Tests layout of fixed positioned dialogs.');
15
16 function checkCentered(dialog) {
17 centeredTop = (window.innerHeight - dialog.offsetHeight) / 2;
18 shouldBe('dialog.getBoundingClientRect().top', 'centeredTop');
19 }
20
21 function reset() {
22 if (dialog.open)
23 dialog.close();
24 dialog.remove();
25 document.body.appendChild(dialog);
26 window.scroll(0, 500);
27 }
28
29 dialog = document.querySelector('#dialog');
30 absoluteContainer = document.querySelector('#absolute-div');
31 relativeContainer = document.querySelector('#relative-div');
32 reset();
33
34 (function() {
35 debug('<br>showModal() should center in the viewport.');
36
37 dialog.showModal();
38 checkCentered(dialog);
39 reset();
40 }());
41
42 (function() {
43 debug('<br>The dialog is a positioned element, so the top and bottom should not have style auto.');
44
45 dialog.style.height = '20px';
46 dialog.showModal();
47 shouldBeEqualToString('window.getComputedStyle(dialog).top', '290px');
48 shouldBeEqualToString('window.getComputedStyle(dialog).bottom', '290px');
49
50 dialog.style.height = 'auto';
51 reset();
52 }());
53
54 (function() {
55 debug('<br>The dialog shold stay centered on scroll.'),
56
57 dialog.showModal();
58 window.scroll(0, 2 * window.scrollY);
59 checkCentered(dialog);
60 reset();
61 }());
62
63 (function() {
64 debug('<br>A tall dialog should be positioned at the top of the viewport.');
65
66 dialog.style.height = '20000px';
67 dialog.showModal();
68 shouldBe('dialog.getBoundingClientRect().top', '0');
69
70 dialog.style.height = 'auto';
71 reset();
72 }());
73
74 (function() {
75 debug('<br>The dialog should be centered regardless of the presence of a hor izontal scrollbar.');
76
77 document.body.style.width = '4000px';
78 dialog.showModal();
79 checkCentered(dialog);
80
81 document.body.style.width = 'auto';
82 reset();
83 }());
84
85 (function() {
86 debug('<br>Centering should work when dialog is inside positioned containers .');
87
88 dialog.remove();
89 absoluteContainer.appendChild(dialog);
90 dialog.showModal();
91 checkCentered(dialog);
92 dialog.close();
93
94 dialog.remove();
95 relativeContainer.appendChild(dialog);
96 dialog.showModal();
97 checkCentered(dialog);
98
99 reset();
100 }());
101
102 (function() {
103 debug('<br>A centered dialog\'s position should survive becoming display:non e temporarily.');
104
105 dialog.showModal();
106 expectedTop = dialog.getBoundingClientRect().top;
107 relativeContainer.style.display = 'none';
108 relativeContainer.style.display = 'block';
109 shouldBe('dialog.getBoundingClientRect().top', 'expectedTop');
110
111 reset();
112 }());
113
114 (function() {
115 debug('<br>Dialog should lose centering when removed from the document.');
116
117 dialog.showModal();
118 dialog.remove();
119 relativeContainer.appendChild(dialog);
120 shouldBe('dialog.getBoundingClientRect().top', '0');
121
122 reset();
123 }());
124
125 (function() {
126 debug('<br>Dialog\'s specified position should survive after close() and sho wModal().');
127
128 dialog.showModal();
129 dialog.style.top = '0px';
130 expectedTop = dialog.getBoundingClientRect().top;
131 dialog.close();
132 dialog.showModal();
133 shouldBe('dialog.getBoundingClientRect().top', 'expectedTop');
134
135 dialog.style.top = 'auto';
136 reset();
137 }());
138
139 (function() {
140 debug('<br>Dialog should not be centered if showModal() was called when an a ncestor had display \'none\'.');
141
142 dialog.remove();
143 absoluteContainer.appendChild(dialog);
144 absoluteContainer.style.display = 'none';
145 dialog.showModal();
146 absoluteContainer.style.display = 'block';
147 shouldBe('dialog.getBoundingClientRect().top', '0');
148
149 reset();
150 }());
151
152 (function() {
153 debug('<br>A dialog with specified \'top\' should be positioned as usual');
154 offset = 50;
155 dialog.style.top = offset + 'px';
156 dialog.showModal();
157 shouldBe('dialog.getBoundingClientRect().top', 'offset');
158
159 reset();
160 }());
161 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698