|
45 | 45 | const {popUp, descendent} = createPopUp(t,'animation');
|
46 | 46 | assert_false(isElementVisible(popUp));
|
47 | 47 | assert_equals(descendent.parentElement.parentElement,popUp);
|
| 48 | + assert_true(popUp.matches(':closed')); |
| 49 | + assert_false(popUp.matches(':open')); |
48 | 50 | popUp.showPopUp();
|
| 51 | + assert_false(popUp.matches(':closed')); |
49 | 52 | assert_true(popUp.matches(':open'));
|
50 | 53 | assert_true(isElementVisible(popUp));
|
51 | 54 | assert_equals(popUp.getAnimations({subtree: true}).length,0);
|
52 | 55 | popUp.hidePopUp();
|
53 | 56 | const animations = popUp.getAnimations({subtree: true});
|
54 | 57 | assert_equals(animations.length,2,'There should be two animations running');
|
55 | 58 | assert_false(popUp.matches(':open'),'popUp should not match :open as soon as hidden');
|
| 59 | + assert_false(popUp.matches(':closed'),'popUp should not match :closed until animations complete'); |
56 | 60 | assert_true(isElementVisible(popUp),'but animations should keep the popUp visible');
|
57 | 61 | assert_true(isElementVisible(descendent),'The descendent should also be visible');
|
58 | 62 | await waitForRender();
|
|
61 | 65 | assert_true(isElementVisible(popUp),'PopUp should still be visible due to animation');
|
62 | 66 | animations.forEach(animation => animation.finish()); // Force the animations to finish
|
63 | 67 | await waitForRender(); // Wait one frame
|
| 68 | + assert_true(popUp.matches(':closed'),'The pop up should now match :closed'); |
64 | 69 | assert_false(popUp.matches(':open'),'The pop up still shouldn\'t match :open');
|
65 | 70 | assert_false(isElementVisible(popUp),'The pop up should now be invisible');
|
66 | 71 | assert_false(isElementVisible(descendent),'The descendent should also be invisible');
|
|
82 | 87 | // Then hide the popUp.
|
83 | 88 | popUp.hidePopUp();
|
84 | 89 | assert_false(popUp.matches(':open'),'pop up should not match :open as soon as hidden');
|
| 90 | + assert_true(popUp.matches(':closed'),'pop up should match :closed immediately'); |
85 | 91 | assert_equals(popUp.getAnimations({subtree: true}).length,2,'animations should still be running');
|
86 | 92 | await waitForRender();
|
87 | 93 | assert_equals(popUp.getAnimations({subtree: true}).length,2,'animations should still be running');
|
|
137 | 143 | assert_false(isElementVisible(popUp),'Even if hide event is cancelled, the popup still closes');
|
138 | 144 | },'hide event cannot be cancelled');
|
139 | 145 |
|
| 146 | +promise_test(async (t) => { |
| 147 | + const {popUp, descendent} = createPopUp(t,'animation'); |
| 148 | + assert_false(isElementVisible(popUp)); |
| 149 | + popUp.showPopUp(); |
| 150 | + assert_false(popUp.matches(':closed')); |
| 151 | + assert_true(popUp.matches(':open')); |
| 152 | + assert_true(isElementVisible(popUp)); |
| 153 | + assert_equals(popUp.getAnimations({subtree: true}).length,0); |
| 154 | + popUp.popUp = 'manual'; |
| 155 | + const animations = popUp.getAnimations({subtree: true}); |
| 156 | + assert_equals(animations.length,2,'There should be two animations running'); |
| 157 | + assert_false(popUp.matches(':open'),'popUp should not match :open as soon as hidden'); |
| 158 | + assert_false(popUp.matches(':closed'),'popUp should not match :closed until animations complete'); |
| 159 | + assert_true(isElementVisible(popUp),'but animations should keep the popUp visible'); |
| 160 | + animations.forEach(animation => animation.finish()); // Force the animations to finish |
| 161 | + await waitForRender(); // Wait one frame |
| 162 | + assert_true(popUp.matches(':closed'),'The pop up should now match :closed'); |
| 163 | + assert_false(popUp.matches(':open'),'The pop up still shouldn\'t match :open'); |
| 164 | + assert_false(isElementVisible(popUp),'The pop up should now be invisible'); |
| 165 | +},'Closing animations are triggered by changing the pop-up type'); |
| 166 | + |
140 | 167 | promise_test(async (t) => {
|
141 | 168 | const {popUp, descendent} = createPopUp(t,'');
|
142 | 169 | popUp.showPopUp();
|
|
0 commit comments