@@ -318,6 +318,32 @@ 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 (explained, contains ('url=$src ,' ));
326+ });
327+
328+ testWidgets ('src takes priority over data-src' , (tester) async {
329+ const html = '<iframe data-src="$src /1" src="$src /2"></iframe>' ;
330+ final explained = await explain (tester, html);
331+ expect (explained, contains ('url=$src /2,' ));
332+ });
333+
334+ testWidgets ('falls back to data-src when src is empty' , (tester) async {
335+ const html = '<iframe data-src="$src " src=""></iframe>' ;
336+ final explained = await explain (tester, html);
337+ expect (explained, contains ('url=$src ,' ));
338+ });
339+
340+ testWidgets ('uses src when data-src is missing' , (tester) async {
341+ const html = '<iframe src="$src "></iframe>' ;
342+ final explained = await explain (tester, html);
343+ expect (explained, contains ('url=$src ,' ));
344+ });
345+ });
346+
321347 group ('errors' , () {
322348 testWidgets ('no src' , (tester) async {
323349 const html = '<iframe></iframe>' ;
@@ -330,6 +356,12 @@ void main() {
330356 final explained = await explain (tester, html);
331357 expect (explained, equals ('[widget0]' ));
332358 });
359+
360+ testWidgets ('bad data-src (cannot build full url)' , (tester) async {
361+ const html = '<iframe data-src="bad"></iframe>' ;
362+ final explained = await explain (tester, html);
363+ expect (explained, equals ('[widget0]' ));
364+ });
333365 });
334366}
335367
0 commit comments