@@ -44,6 +44,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
44
44
// Symbols for our own info on Nodes/StyleSheets.
45
45
const kSnapshotFrameId = Symbol ( '__playwright_snapshot_frameid_' ) ;
46
46
const kCachedData = Symbol ( '__playwright_snapshot_cache_' ) ;
47
+ const kEndOfList = Symbol ( '__playwright_end_of_list_' ) ;
47
48
type CachedData = {
48
49
cached ?: any [ ] , // Cached values to determine whether the snapshot will be the same.
49
50
ref ?: [ number , number ] , // Previous snapshotNumber and nodeIndex.
@@ -355,6 +356,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
355
356
}
356
357
for ( let child = node . firstChild ; child ; child = child . nextSibling )
357
358
visitChild ( child ) ;
359
+ expectValue ( kEndOfList ) ;
358
360
let documentOrShadowRoot = null ;
359
361
if ( node . ownerDocument ! . documentElement === node )
360
362
documentOrShadowRoot = node . ownerDocument ;
@@ -363,20 +365,19 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
363
365
if ( documentOrShadowRoot ) {
364
366
for ( const sheet of ( documentOrShadowRoot as any ) . adoptedStyleSheets || [ ] )
365
367
visitChildStyleSheet ( sheet ) ;
368
+ expectValue ( kEndOfList ) ;
366
369
}
367
370
}
368
371
369
372
// Process iframe src attribute before bailing out since it depends on a symbol, not the DOM.
370
373
if ( nodeName === 'IFRAME' || nodeName === 'FRAME' ) {
371
374
const element = node as Element ;
372
- for ( let i = 0 ; i < element . attributes . length ; i ++ ) {
373
- const frameId = ( element as any ) [ kSnapshotFrameId ] ;
374
- const name = 'src' ;
375
- const value = frameId ? `/snapshot/${ frameId } ` : '' ;
376
- expectValue ( name ) ;
377
- expectValue ( value ) ;
378
- attrs [ name ] = value ;
379
- }
375
+ const frameId = ( element as any ) [ kSnapshotFrameId ] ;
376
+ const name = 'src' ;
377
+ const value = frameId ? `/snapshot/${ frameId } ` : '' ;
378
+ expectValue ( name ) ;
379
+ expectValue ( value ) ;
380
+ attrs [ name ] = value ;
380
381
}
381
382
382
383
// We can skip attributes comparison because nothing else has changed,
@@ -409,6 +410,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
409
410
expectValue ( value ) ;
410
411
attrs [ name ] = value ;
411
412
}
413
+ expectValue ( kEndOfList ) ;
412
414
}
413
415
414
416
if ( result . length === 2 && ! Object . keys ( attrs ) . length )
0 commit comments