Skip to content

Commit 71d1791

Browse files
committed
Fixing bot.inject.recompileFunction_ to work for frames in IE5 quirks mode
1 parent 84eccdd commit 71d1791

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

javascript/atoms/inject.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ bot.inject.unwrapValue = function(value, opt_doc) {
183183
*/
184184
bot.inject.recompileFunction_ = function(fn, theWindow) {
185185
if (goog.isString(fn)) {
186-
return new theWindow['Function'](fn);
186+
try {
187+
return new theWindow['Function'](fn);
188+
} catch (ex) {
189+
// Try to recover if in IE5-quirks mode
190+
// Need to initialize the script engine on the passed-in window
191+
if (goog.userAgent.IE && theWindow.execScript) {
192+
theWindow.execScript(';');
193+
return new theWindow['Function'](fn);
194+
}
195+
throw ex;
196+
}
187197
}
188198
return theWindow == window ? fn : new theWindow['Function'](
189199
'return (' + fn + ').apply(null,arguments);');
@@ -376,7 +386,7 @@ bot.inject.wrapError = function(err) {
376386
err['code'] : bot.ErrorCode.UNKNOWN_ERROR,
377387
// TODO: Parse stackTrace
378388
'value': {
379-
'message': err.message
389+
'message': err.message + '\n' + (err.stack || '')
380390
}
381391
};
382392
};

0 commit comments

Comments
 (0)