@@ -318,6 +318,61 @@ void main() {
318318 });
319319 });
320320
321+ group ('data-src attribute' , () {
322+ testWidgets ('renders with data-src' , (tester) async {
323+ const html = '<iframe data-src="$src "></iframe>' ;
324+ final explained = await explain (tester, html);
325+ expect (
326+ explained,
327+ equals (
328+ '[CssSizing:$sizingConstraints ,child='
329+ '[WebView:url=$src ,aspectRatio=$defaultAspectRatio ,js=true,gestureRecognizers={}]'
330+ ']' ,
331+ ),
332+ );
333+ });
334+
335+ testWidgets ('data-src takes priority over src' , (tester) async {
336+ const dataSrcUrl = 'http://data-src.com' ;
337+ const html = '<iframe data-src="$dataSrcUrl " src="$src "></iframe>' ;
338+ final explained = await explain (tester, html);
339+ expect (
340+ explained,
341+ equals (
342+ '[CssSizing:$sizingConstraints ,child='
343+ '[WebView:url=$dataSrcUrl ,aspectRatio=$defaultAspectRatio ,js=true,gestureRecognizers={}]'
344+ ']' ,
345+ ),
346+ );
347+ });
348+
349+ testWidgets ('falls back to src when data-src is empty' , (tester) async {
350+ const html = '<iframe data-src="" src="$src "></iframe>' ;
351+ final explained = await explain (tester, html);
352+ expect (
353+ explained,
354+ equals (
355+ '[CssSizing:$sizingConstraints ,child='
356+ '[WebView:url=$src ,aspectRatio=$defaultAspectRatio ,js=true,gestureRecognizers={}]'
357+ ']' ,
358+ ),
359+ );
360+ });
361+
362+ testWidgets ('falls back to src when data-src is missing' , (tester) async {
363+ const html = '<iframe src="$src "></iframe>' ;
364+ final explained = await explain (tester, html);
365+ expect (
366+ explained,
367+ equals (
368+ '[CssSizing:$sizingConstraints ,child='
369+ '[WebView:url=$src ,aspectRatio=$defaultAspectRatio ,js=true,gestureRecognizers={}]'
370+ ']' ,
371+ ),
372+ );
373+ });
374+ });
375+
321376 group ('errors' , () {
322377 testWidgets ('no src' , (tester) async {
323378 const html = '<iframe></iframe>' ;
@@ -330,6 +385,12 @@ void main() {
330385 final explained = await explain (tester, html);
331386 expect (explained, equals ('[widget0]' ));
332387 });
388+
389+ testWidgets ('bad data-src (cannot build full url)' , (tester) async {
390+ const html = '<iframe data-src="bad"></iframe>' ;
391+ final explained = await explain (tester, html);
392+ expect (explained, equals ('[widget0]' ));
393+ });
333394 });
334395}
335396
0 commit comments