Bug 637572 - Implement Debugger.Source.prototype.url; r=jimb

--HG--
rename : js/src/jit-test/tests/debug/Script-url.js => js/src/jit-test/tests/debug/Source-url.js
This commit is contained in:
Eddy Bruel 2013-05-28 13:02:55 -07:00
parent 24eca4433d
commit 070460ebdf
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,10 @@
// Source.prototype.url can be a string or null.
var g = newGlobal('new-compartment');
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
for (var fileName of ['file:///var/foo.js', null]) {
g.evaluate("function f(x) { return 2*x; }", {fileName: fileName});
var fw = gw.getOwnPropertyDescriptor('f').value;
assertEq(fw.script.source.url, fileName);
}

View File

@ -3656,8 +3656,26 @@ DebuggerSource_getText(JSContext *cx, unsigned argc, Value *vp)
return true;
}
static JSBool
DebuggerSource_getUrl(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get url)", args, obj, sourceObject);
ScriptSource *ss = sourceObject->source();
if (ss->filename()) {
JSString *str = js_NewStringCopyZ<CanGC>(cx, ss->filename());
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),
JS_PS_END
};