diff --git a/tests/web/deferred_fail_and_retry_test.dart b/tests/web/deferred_fail_and_retry_test.dart index 5c62639502e..242457c5f35 100644 --- a/tests/web/deferred_fail_and_retry_test.dart +++ b/tests/web/deferred_fail_and_retry_test.dart @@ -15,7 +15,7 @@ main() { js.context.callMethod("eval", [ """ retryCount = 0; - if (self.document) { + if (self.document && self.document.body) { oldAppendChild = document.body.appendChild; replacement = function(element) { element.src = "non_existing.js"; diff --git a/tests/web_2/deferred_fail_and_retry_test.dart b/tests/web_2/deferred_fail_and_retry_test.dart index c57c709054f..bd4ad7855d8 100644 --- a/tests/web_2/deferred_fail_and_retry_test.dart +++ b/tests/web_2/deferred_fail_and_retry_test.dart @@ -17,7 +17,7 @@ main() { js.context.callMethod("eval", [ """ retryCount = 0; - if (self.document) { + if (self.document && self.document.body) { oldAppendChild = document.body.appendChild; replacement = function(element) { element.src = "non_existing.js";