зеркало из https://github.com/mozilla/gecko-dev.git
Bug 819049: JS debugging protocol: provide 'name', 'displayName', and 'userDisplayName' properties on function grips. r=past
This commit is contained in:
Родитель
aeef591b0c
Коммит
f0e8a6203f
|
@ -1507,9 +1507,27 @@ update(ObjectActor.prototype, {
|
|||
* Returns a grip for this actor for returning in a protocol message.
|
||||
*/
|
||||
grip: function OA_grip() {
|
||||
return { "type": "object",
|
||||
"class": this.obj.class,
|
||||
"actor": this.actorID };
|
||||
let g = { "type": "object",
|
||||
"class": this.obj.class,
|
||||
"actor": this.actorID };
|
||||
|
||||
// Add additional properties for functions.
|
||||
if (this.obj.class === "Function") {
|
||||
if (this.obj.name) {
|
||||
g.name = this.obj.name;
|
||||
} else if (this.obj.displayName) {
|
||||
g.displayName = this.obj.displayName;
|
||||
}
|
||||
|
||||
// Check if the developer has added a de-facto standard displayName
|
||||
// property for us to use.
|
||||
let desc = this.obj.getOwnPropertyDescriptor("displayName");
|
||||
if (desc && desc.value && typeof desc.value == "string") {
|
||||
g.userDisplayName = this.threadActor.createValueGrip(desc.value);
|
||||
}
|
||||
}
|
||||
|
||||
return g;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ function test_named_function()
|
|||
let args = aPacket.frame.arguments;
|
||||
|
||||
do_check_eq(args[0].class, "Function");
|
||||
// No name for an anonymous function.
|
||||
do_check_eq(args[0].name, "stopMe");
|
||||
|
||||
let objClient = gThreadClient.pauseGrip(args[0]);
|
||||
objClient.getSignature(function(aResponse) {
|
||||
|
@ -37,9 +37,7 @@ function test_named_function()
|
|||
do_check_eq(aResponse.parameters.length, 1);
|
||||
do_check_eq(aResponse.parameters[0], "arg1");
|
||||
|
||||
gThreadClient.resume(function() {
|
||||
test_anon_function();
|
||||
});
|
||||
gThreadClient.resume(test_inferred_name_function);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -47,12 +45,38 @@ function test_named_function()
|
|||
gDebuggee.eval("stopMe(stopMe)");
|
||||
}
|
||||
|
||||
function test_anon_function() {
|
||||
function test_inferred_name_function() {
|
||||
gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
|
||||
let args = aPacket.frame.arguments;
|
||||
|
||||
do_check_eq(args[0].class, "Function");
|
||||
// No name for an anonymous function.
|
||||
// No name for an anonymous function, but it should have an inferred name.
|
||||
do_check_eq(args[0].name, undefined);
|
||||
do_check_eq(args[0].displayName, "o.m");
|
||||
|
||||
let objClient = gThreadClient.pauseGrip(args[0]);
|
||||
objClient.getSignature(function(aResponse) {
|
||||
do_check_eq(aResponse.name, null);
|
||||
do_check_eq(aResponse.parameters.length, 3);
|
||||
do_check_eq(aResponse.parameters[0], "foo");
|
||||
do_check_eq(aResponse.parameters[1], "bar");
|
||||
do_check_eq(aResponse.parameters[2], "baz");
|
||||
|
||||
gThreadClient.resume(test_anonymous_function);
|
||||
});
|
||||
});
|
||||
|
||||
gDebuggee.eval("var o = { m: function(foo, bar, baz) { } }; stopMe(o.m)");
|
||||
}
|
||||
|
||||
function test_anonymous_function() {
|
||||
gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
|
||||
let args = aPacket.frame.arguments;
|
||||
|
||||
do_check_eq(args[0].class, "Function");
|
||||
// No name for an anonymous function, and no inferred name, either.
|
||||
do_check_eq(args[0].name, undefined);
|
||||
do_check_eq(args[0].displayName, undefined);
|
||||
|
||||
let objClient = gThreadClient.pauseGrip(args[0]);
|
||||
objClient.getSignature(function(aResponse) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче