@@ -129,20 +129,16 @@ test('applies polyfill for `@position-fallback`', async ({ page }) => {
129
129
130
130
test ( 'applies manual polyfill' , async ( { page } ) => {
131
131
await page . locator ( '#apply-polyfill-manually' ) . click ( ) ;
132
- const anchorBox = await page . locator ( '#my-anchor-manual' ) . boundingBox ( ) ;
133
- const target1Box = await page
132
+ const anchorBox = ( await page . locator ( '#my-anchor-manual' ) . boundingBox ( ) ) ! ;
133
+ const target1Box = ( await page
134
134
. locator ( '#my-target-manual-style-el' )
135
- . boundingBox ( ) ;
136
- const target2Box = await page
135
+ . boundingBox ( ) ) ! ;
136
+ const target2Box = ( await page
137
137
. locator ( '#my-target-manual-link-el' )
138
- . boundingBox ( ) ;
139
- const target3Box = await page
138
+ . boundingBox ( ) ) ! ;
139
+ const target3Box = ( await page
140
140
. locator ( '#my-target-manual-inline-style' )
141
- . boundingBox ( ) ;
142
-
143
- if ( ! anchorBox || ! target1Box || ! target2Box || ! target3Box ) {
144
- return ;
145
- }
141
+ . boundingBox ( ) ) ! ;
146
142
147
143
expect ( target1Box . x + target1Box . width ) . toBeCloseTo ( anchorBox . x , 0 ) ;
148
144
expect ( target1Box . y + target1Box . height ) . toBeCloseTo ( anchorBox . y , 0 ) ;
@@ -153,3 +149,63 @@ test('applies manual polyfill', async ({ page }) => {
153
149
expect ( target3Box . x ) . toBeCloseTo ( anchorBox . x + anchorBox . width , 0 ) ;
154
150
expect ( target3Box . y ) . toBeCloseTo ( anchorBox . y + anchorBox . height , 0 ) ;
155
151
} ) ;
152
+
153
+ test ( 'applies manual polyfill for multiple elements separately' , async ( {
154
+ page,
155
+ } ) => {
156
+ const buttonContainer = page . locator ( '#anchor-manual-test-buttons' ) ;
157
+ await buttonContainer . evaluate ( ( node : HTMLDivElement ) => {
158
+ node . hidden = false ;
159
+ } ) ;
160
+ await buttonContainer . waitFor ( { state : 'visible' } ) ;
161
+
162
+ const prepareButton = page . locator ( '#prepare-manual-polyfill' ) ;
163
+ await prepareButton . click ( ) ;
164
+
165
+ const anchorBox = ( await page . locator ( '#my-anchor-manual' ) . boundingBox ( ) ) ! ;
166
+ const target1Box = ( await page
167
+ . locator ( '#my-target-manual-style-el' )
168
+ . boundingBox ( ) ) ! ;
169
+ const target2Box = ( await page
170
+ . locator ( '#my-target-manual-link-el' )
171
+ . boundingBox ( ) ) ! ;
172
+ const target3Box = ( await page
173
+ . locator ( '#my-target-manual-inline-style' )
174
+ . boundingBox ( ) ) ! ;
175
+
176
+ expect ( target1Box . x + target1Box . width ) . not . toBeCloseTo ( anchorBox . x , 0 ) ;
177
+ expect ( target1Box . y + target1Box . height ) . not . toBeCloseTo ( anchorBox . y , 0 ) ;
178
+
179
+ expect ( target2Box . x ) . not . toBeCloseTo ( anchorBox . x + anchorBox . width , 0 ) ;
180
+ expect ( target2Box . y + target2Box . height ) . not . toBeCloseTo ( anchorBox . y , 0 ) ;
181
+
182
+ expect ( target3Box . x ) . not . toBeCloseTo ( anchorBox . x + anchorBox . width , 0 ) ;
183
+ expect ( target3Box . y ) . not . toBeCloseTo ( anchorBox . y + anchorBox . height , 0 ) ;
184
+
185
+ const set1Button = page . locator ( '#apply-polyfill-manually-set1' ) ;
186
+ const set2Button = page . locator ( '#apply-polyfill-manually-set2' ) ;
187
+
188
+ await set1Button . click ( ) ;
189
+
190
+ const newTarget1Box = ( await page
191
+ . locator ( '#my-target-manual-style-el' )
192
+ . boundingBox ( ) ) ! ;
193
+
194
+ expect ( newTarget1Box . x + newTarget1Box . width ) . toBeCloseTo ( anchorBox . x , 0 ) ;
195
+ expect ( newTarget1Box . y + newTarget1Box . height ) . toBeCloseTo ( anchorBox . y , 0 ) ;
196
+
197
+ await set2Button . click ( ) ;
198
+
199
+ const newTarget2Box = ( await page
200
+ . locator ( '#my-target-manual-link-el' )
201
+ . boundingBox ( ) ) ! ;
202
+ const newTarget3Box = ( await page
203
+ . locator ( '#my-target-manual-inline-style' )
204
+ . boundingBox ( ) ) ! ;
205
+
206
+ expect ( newTarget2Box . x ) . toBeCloseTo ( anchorBox . x + anchorBox . width , 0 ) ;
207
+ expect ( newTarget2Box . y + newTarget2Box . height ) . toBeCloseTo ( anchorBox . y , 0 ) ;
208
+
209
+ expect ( newTarget3Box . x ) . toBeCloseTo ( anchorBox . x + anchorBox . width , 0 ) ;
210
+ expect ( newTarget3Box . y ) . toBeCloseTo ( anchorBox . y + anchorBox . height , 0 ) ;
211
+ } ) ;
0 commit comments