Skip to content

Commit 27ddf83

Browse files
fix(android): Catch errors in WebView injection (#4943)
Co-authored-by: mark.dev <50657916+markdevocht@users.noreply.github.com>
1 parent 650e4c5 commit 27ddf83

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

detox/android/detox/src/full/java/com/wix/detox/espresso/hierarchy/ViewHierarchyGenerator.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import kotlin.coroutines.resume
1919

2020
private const val GET_HTML_SCRIPT = """
2121
(function() {
22+
try {
2223
const blacklistedTags = ['script', 'style', 'head', 'meta'];
2324
const blackListedTagsSelector = blacklistedTags.join(',');
2425
@@ -38,7 +39,10 @@ private const val GET_HTML_SCRIPT = """
3839
var serializedHtml = serializer.serializeToString(clonedDoc);
3940
4041
// Return the serialized HTML as a string
41-
return serializedHtml;
42+
return serializedHtml;
43+
} catch {
44+
return '<html xmlns="http://www.w3.org/1999/xhtml"><body></body></html>';
45+
}
4246
})();
4347
"""
4448

0 commit comments

Comments
 (0)