Bug 791157: Make sure the shell's 'evaluate' function properly restores the JSContext options. r=jorendorff

This commit is contained in:
Jim Blandy 2012-09-21 16:10:30 -07:00
Родитель 395fc4a655
Коммит 759463be71
2 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,11 @@
// Bug 791157: the shell 'evaluate' function should properly restore the
// context's options.
try {
evaluate('%', {noScriptRval: true});
} catch(e) {}
new Function("");
try {
evaluate('new Function("");', {noScriptRval: true});
} catch (e) {}

Просмотреть файл

@ -902,16 +902,17 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
options |= JSOPTION_COMPILE_N_GO;
if (noScriptRval)
options |= JSOPTION_NO_SCRIPT_RVAL;
JS_SetOptions(cx, options);
JS_SetOptions(cx, options);
JSScript *script = JS_CompileUCScript(cx, global, codeChars, codeLength, fileName, lineNumber);
JS_SetOptions(cx, saved);
if (!script)
return false;
if (sourceMapURL && !script->scriptSource()->hasSourceMap()) {
if (!script->scriptSource()->setSourceMap(cx, sourceMapURL, script->filename))
return false;
}
JS_SetOptions(cx, saved);
if (!JS_ExecuteScript(cx, global, script, vp))
return false;
}