Bug 1056409 - move the sourceMapURL property from Debugger.Script to Debugger.Source. r=jorendorff

This commit is contained in:
James Long 2014-10-06 11:42:00 +02:00
parent 747e037691
commit 347d6e4d33
8 changed files with 44 additions and 44 deletions

View File

@ -46,7 +46,7 @@ window.onload = function () {
});
ok(scripts.length > 0, "Should be able to find script");
is(scripts[0].sourceMapURL, "foo.js.map");
is(scripts[0].source.sourceMapURL, "foo.js.map");
SimpleTest.finish();
}

View File

@ -115,17 +115,6 @@ from its prototype:
: This is `true` if this script's code is ECMAScript strict mode code, and
`false` otherwise.
`sourceMapURL`
: If this script was produced by a minimizer or translated from some other
language, and we know the URL of a <b>source map</b> document relating
the source positions in this script to the corresponding source
positions in the original source, then this property's value is that
URL. Otherwise, this is `null`.
(On the web, the translator may provide the source map URL in a
specially formatted comment in the JavaScript source code, or via a
header in the HTTP reply that carried the generated JavaScript.)
## Function Properties of the Debugger.Script Prototype Object
The functions described below may only be called with a `this` value

View File

@ -74,6 +74,17 @@ from its prototype:
`url` accessor on `Debugger.Source` instances for such sources should
return `undefined`.)
`sourceMapURL`
: If this source was produced by a minimizer or translated from some other
language, and we know the URL of a <b>source map</b> document relating
the source positions in this source to the corresponding source
positions in the original source, then this property's value is that
URL. Otherwise, this is `null`.
(On the web, the translator may provide the source map URL in a
specially formatted comment in the JavaScript source code, or via a
header in the HTTP reply that carried the generated JavaScript.)
`element`
: The [`Debugger.Object`][object] instance referring to the DOM element to which
this source code belongs, if any, or `undefined` if it belongs to no DOM

View File

@ -78,7 +78,7 @@ var capturedSourceMapURL;
dbg.onNewScript = function (script) {
capturedScript = script;
capturedDisplayURL = script.source.displayURL;
capturedSourceMapURL = script.sourceMapURL;
capturedSourceMapURL = script.source.sourceMapURL;
dbg.onNewScript = undefined;
};
var fun = gw.makeDebuggeeValue(g.Function('//# sourceURL=munge.js\n//# sourceMappingURL=grunge.map\n'));
@ -87,5 +87,5 @@ assertEq(capturedScript, fun.script);
assertEq(capturedDisplayURL, fun.script.source.displayURL);
assertEq(capturedDisplayURL, 'munge.js');
assertEq(capturedSourceMapURL, fun.script.sourceMapURL);
assertEq(capturedSourceMapURL, fun.script.source.sourceMapURL);
assertEq(capturedSourceMapURL, 'grunge.map');

View File

@ -1,4 +1,4 @@
// Script.prototype.sourceMapURL can be a string or null.
// Source.prototype.sourceMapURL can be a string or null.
let g = newGlobal();
let dbg = new Debugger;
@ -6,7 +6,7 @@ let gw = dbg.addDebuggee(g);
function getSourceMapURL() {
let fw = gw.makeDebuggeeValue(g.f);
return fw.script.sourceMapURL;
return fw.script.source.sourceMapURL;
}
// Without a source map
@ -21,7 +21,7 @@ assertEq(getSourceMapURL(), 'file:///var/foo.js.map');
let fired = false;
dbg.onDebuggerStatement = function (frame) {
fired = true;
assertEq(frame.script.sourceMapURL, 'file:///var/bar.js.map');
assertEq(frame.script.source.sourceMapURL, 'file:///var/bar.js.map');
};
g.evaluate('(function () { (function () { debugger; })(); })();',
{sourceMapURL: 'file:///var/bar.js.map'});

View File

@ -1,4 +1,4 @@
// Script.prototype.sourceMapURL can be a string or null.
// Source.prototype.sourceMapURL can be a string or null.
let g = newGlobal();
let dbg = new Debugger;
@ -6,7 +6,7 @@ let gw = dbg.addDebuggee(g);
function getSourceMapURL() {
let fw = gw.makeDebuggeeValue(g.f);
return fw.script.sourceMapURL;
return fw.script.source.sourceMapURL;
}
// Without a source map
@ -21,7 +21,7 @@ assertEq(getSourceMapURL(), 'file:///var/foo.js.map');
let fired = false;
dbg.onDebuggerStatement = function (frame) {
fired = true;
assertEq(frame.script.sourceMapURL, 'file:///var/bar.js.map');
assertEq(frame.script.source.sourceMapURL, 'file:///var/bar.js.map');
};
g.evaluate('(function () { (function () { debugger; })(); })();',
{sourceMapURL: 'file:///var/bar.js.map'});

View File

@ -3261,26 +3261,6 @@ DebuggerScript_getStaticLevel(JSContext *cx, unsigned argc, Value *vp)
return true;
}
static bool
DebuggerScript_getSourceMapUrl(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "(get sourceMapURL)", args, obj, script);
ScriptSource *source = script->scriptSource();
MOZ_ASSERT(source);
if (source->hasSourceMapURL()) {
JSString *str = JS_NewUCStringCopyZ(cx, source->sourceMapURL());
if (!str)
return false;
args.rval().setString(str);
} else {
args.rval().setNull();
}
return true;
}
static bool
DebuggerScript_getGlobal(JSContext *cx, unsigned argc, Value *vp)
{
@ -4011,7 +3991,6 @@ static const JSPropertySpec DebuggerScript_properties[] = {
JS_PSG("sourceStart", DebuggerScript_getSourceStart, 0),
JS_PSG("sourceLength", DebuggerScript_getSourceLength, 0),
JS_PSG("staticLevel", DebuggerScript_getStaticLevel, 0),
JS_PSG("sourceMapURL", DebuggerScript_getSourceMapUrl, 0),
JS_PSG("global", DebuggerScript_getGlobal, 0),
JS_PS_END
};
@ -4280,6 +4259,26 @@ DebuggerSource_getIntroductionType(JSContext *cx, unsigned argc, Value *vp)
return true;
}
static bool
DebuggerSource_getSourceMapUrl(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get sourceMapURL)", args, obj, sourceObject);
ScriptSource *ss = sourceObject->source();
MOZ_ASSERT(ss);
if (ss->hasSourceMapURL()) {
JSString *str = JS_NewUCStringCopyZ(cx, ss->sourceMapURL());
if (!str)
return false;
args.rval().setString(str);
} else {
args.rval().setNull();
}
return true;
}
static const JSPropertySpec DebuggerSource_properties[] = {
JS_PSG("text", DebuggerSource_getText, 0),
JS_PSG("url", DebuggerSource_getUrl, 0),
@ -4289,6 +4288,7 @@ static const JSPropertySpec DebuggerSource_properties[] = {
JS_PSG("introductionOffset", DebuggerSource_getIntroductionOffset, 0),
JS_PSG("introductionType", DebuggerSource_getIntroductionType, 0),
JS_PSG("elementAttributeName", DebuggerSource_getElementProperty, 0),
JS_PSG("sourceMapURL", DebuggerSource_getSourceMapUrl, 0),
JS_PS_END
};

View File

@ -5026,7 +5026,7 @@ ThreadSources.prototype = {
* of an array of source actors for those.
*/
sourcesForScript: function (aScript) {
if (!this._useSourceMaps || !aScript.sourceMapURL) {
if (!this._useSourceMaps || !aScript.source.sourceMapURL) {
return resolve([this._sourceForScript(aScript)].filter(isNotNull));
}
@ -5053,8 +5053,8 @@ ThreadSources.prototype = {
* |aScript| must have a non-null sourceMapURL.
*/
sourceMap: function (aScript) {
dbg_assert(aScript.sourceMapURL, "Script should have a sourceMapURL");
let sourceMapURL = this._normalize(aScript.sourceMapURL, aScript.url);
dbg_assert(aScript.source.sourceMapURL, "Script should have a sourceMapURL");
let sourceMapURL = this._normalize(aScript.source.sourceMapURL, aScript.url);
let map = this._fetchSourceMap(sourceMapURL, aScript.url)
.then(aSourceMap => this.saveSourceMap(aSourceMap, aScript.url));
this._sourceMapsByGeneratedSource[aScript.url] = map;