Skip to content

Instantly share code, notes, and snippets.

@jleyba
Last active January 2, 2016 13:09
Show Gist options
  • Save jleyba/8307735 to your computer and use it in GitHub Desktop.
Save jleyba/8307735 to your computer and use it in GitHub Desktop.
bot.inject.recompileFunction_ = function(fn, theWindow) {
if (goog.isString(fn)) {
try {
return new theWindow['Function'](fn);
} catch (ex) {
// Try to recover if in IE-quirks.
if (theWindow.execScript) {
theWindow.execScript('var __$$webdriver_fn$$__ = (function(){' + fn + '\n})');
return theWindow['__$$webdriver_fn$$__'];
}
throw ex;
}
}
return theWindow == window ? fn : new theWindow['Function'](
'return (' + fn + ').apply(null,arguments);');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment