@@ -126,3 +126,98 @@ describe("Text widget", () => {
126
126
} ) ;
127
127
} ) ;
128
128
} ) ;
129
+
130
+ describe ( "Annotation and storage" , ( ) => {
131
+ describe ( "issue14023.pdf" , ( ) => {
132
+ let pages ;
133
+
134
+ beforeAll ( async ( ) => {
135
+ pages = await loadAndWait ( "issue14023.pdf" , "[data-annotation-id='64R']" ) ;
136
+ } ) ;
137
+
138
+ afterAll ( async ( ) => {
139
+ await closePages ( pages ) ;
140
+ } ) ;
141
+
142
+ it ( "must let checkboxes with the same name behave like radio buttons" , async ( ) => {
143
+ const text1 = "hello world!" ;
144
+ const text2 = "!dlrow olleh" ;
145
+ await Promise . all (
146
+ pages . map ( async ( [ browserName , page ] ) => {
147
+ // Text field.
148
+ await page . type ( "#\\36 4R" , text1 ) ;
149
+ // Checkbox.
150
+ await page . click ( "[data-annotation-id='65R']" ) ;
151
+ // Radio.
152
+ await page . click ( "[data-annotation-id='67R']" ) ;
153
+
154
+ for ( const [ pageNumber , textId , checkId , radio1Id , radio2Id ] of [
155
+ [ 2 , "#\\31 8R" , "#\\31 9R" , "#\\32 1R" , "#\\32 0R" ] ,
156
+ [ 5 , "#\\32 3R" , "#\\32 4R" , "#\\32 2R" , "#\\32 5R" ] ,
157
+ ] ) {
158
+ await page . evaluate ( n => {
159
+ window . document
160
+ . querySelectorAll ( `[data-page-number="${ n } "][class="page"]` ) [ 0 ]
161
+ . scrollIntoView ( ) ;
162
+ } , pageNumber ) ;
163
+
164
+ // Need to wait to have a displayed text input.
165
+ await page . waitForSelector ( textId , {
166
+ timeout : 0 ,
167
+ } ) ;
168
+
169
+ const text = await page . $eval ( textId , el => el . value ) ;
170
+ expect ( text ) . withContext ( `In ${ browserName } ` ) . toEqual ( text1 ) ;
171
+
172
+ let checked = await page . $eval ( checkId , el => el . checked ) ;
173
+ expect ( checked ) . toEqual ( true ) ;
174
+
175
+ checked = await page . $eval ( radio1Id , el => el . checked ) ;
176
+ expect ( checked ) . toEqual ( false ) ;
177
+
178
+ checked = await page . $eval ( radio2Id , el => el . checked ) ;
179
+ expect ( checked ) . toEqual ( false ) ;
180
+ }
181
+
182
+ // Change data on page 5 and check that other pages changed.
183
+ // Text field.
184
+ await page . type ( "#\\32 3R" , text2 ) ;
185
+ // Checkbox.
186
+ await page . click ( "[data-annotation-id='24R']" ) ;
187
+ // Radio.
188
+ await page . click ( "[data-annotation-id='25R']" ) ;
189
+
190
+ for ( const [ pageNumber , textId , checkId , radio1Id , radio2Id ] of [
191
+ [ 1 , "#\\36 4R" , "#\\36 5R" , "#\\36 7R" , "#\\36 8R" ] ,
192
+ [ 2 , "#\\31 8R" , "#\\31 9R" , "#\\32 1R" , "#\\32 0R" ] ,
193
+ ] ) {
194
+ await page . evaluate ( n => {
195
+ window . document
196
+ . querySelectorAll ( `[data-page-number="${ n } "][class="page"]` ) [ 0 ]
197
+ . scrollIntoView ( ) ;
198
+ } , pageNumber ) ;
199
+
200
+ // Need to wait to have a displayed text input.
201
+ await page . waitForSelector ( textId , {
202
+ timeout : 0 ,
203
+ } ) ;
204
+
205
+ const text = await page . $eval ( textId , el => el . value ) ;
206
+ expect ( text )
207
+ . withContext ( `In ${ browserName } ` )
208
+ . toEqual ( text2 + text1 ) ;
209
+
210
+ let checked = await page . $eval ( checkId , el => el . checked ) ;
211
+ expect ( checked ) . toEqual ( false ) ;
212
+
213
+ checked = await page . $eval ( radio1Id , el => el . checked ) ;
214
+ expect ( checked ) . toEqual ( false ) ;
215
+
216
+ checked = await page . $eval ( radio2Id , el => el . checked ) ;
217
+ expect ( checked ) . toEqual ( false ) ;
218
+ }
219
+ } )
220
+ ) ;
221
+ } ) ;
222
+ } ) ;
223
+ } ) ;
0 commit comments