Skip to content

Commit cf26e94

Browse files
committed
Preventing driver hangs caused by TypeError: can't access dead object, when a document is removed at the moment we execute some script. Instead of hanging it should throw an exception. Fixes issue 7934
1 parent 7f5b760 commit cf26e94

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

javascript/firefox-driver/js/utils.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,15 @@ Utils.isSVG = function(doc) {
11831183
};
11841184

11851185
Utils.getMainDocumentElement = function(doc) {
1186-
if (Utils.isSVG(doc))
1187-
return doc.documentElement;
1188-
return doc.body;
1186+
try {
1187+
if (Utils.isSVG(doc))
1188+
return doc.documentElement;
1189+
return doc.body;
1190+
} catch (ex) {
1191+
if (ex instanceof TypeError) {
1192+
return null;
1193+
} else {
1194+
throw ex;
1195+
}
1196+
}
11891197
};

0 commit comments

Comments
 (0)