Bug 981987 - Set displayURL before invoking Debugger.onNewScript hook. r=jimb

This commit is contained in:
Simon Lindholm 2014-09-25 09:14:00 -04:00
parent 6ee4111bff
commit ef1343ad6b
2 changed files with 26 additions and 6 deletions

View File

@ -614,6 +614,12 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
if (!NameFunctions(cx, fn))
return false;
if (!SetDisplayURL(cx, parser.tokenStream, ss))
return false;
if (!SetSourceMap(cx, parser.tokenStream, ss))
return false;
if (fn->pn_funbox->function()->isInterpreted()) {
JS_ASSERT(fun == fn->pn_funbox->function());
@ -647,12 +653,6 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
JS_ASSERT(IsAsmJSModuleNative(fun->native()));
}
if (!SetDisplayURL(cx, parser.tokenStream, ss))
return false;
if (!SetSourceMap(cx, parser.tokenStream, ss))
return false;
if (!sct.complete())
return false;

View File

@ -69,3 +69,23 @@ g.evaluate('function f() {}\n' +
{displayURL: 'http://example.com/bar.js'});
assertEq(getDisplayURL(), 'http://example.com/foo.js');
// Bug 981987 reported that we hadn't set sourceURL yet when firing onNewScript
// from the Function constructor.
var capturedScript;
var capturedDisplayURL;
var capturedSourceMapURL;
dbg.onNewScript = function (script) {
capturedScript = script;
capturedDisplayURL = script.source.displayURL;
capturedSourceMapURL = script.sourceMapURL;
dbg.onNewScript = undefined;
};
var fun = gw.makeDebuggeeValue(g.Function('//# sourceURL=munge.js\n//# sourceMappingURL=grunge.map\n'));
assertEq(capturedScript, fun.script);
assertEq(capturedDisplayURL, fun.script.source.displayURL);
assertEq(capturedDisplayURL, 'munge.js');
assertEq(capturedSourceMapURL, fun.script.sourceMapURL);
assertEq(capturedSourceMapURL, 'grunge.map');