Skip to content

Commit

Permalink
Preventing driver hangs caused by TypeError: can't access dead object…
Browse files Browse the repository at this point in the history
…, when a document is removed at the moment we execute some script. Instead of hanging it should throw an exception. Fixes issue 7934
  • Loading branch information
barancev committed Sep 22, 2014
1 parent 7f5b760 commit cf26e94
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions javascript/firefox-driver/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,15 @@ Utils.isSVG = function(doc) {
};

Utils.getMainDocumentElement = function(doc) {
if (Utils.isSVG(doc))
return doc.documentElement;
return doc.body;
try {
if (Utils.isSVG(doc))
return doc.documentElement;
return doc.body;
} catch (ex) {
if (ex instanceof TypeError) {
return null;
} else {
throw ex;
}
}
};

0 comments on commit cf26e94

Please sign in to comment.