toolkit/devtools/server/tests/unit/test_objectgrips-10.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:b53bc5bab7fe
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 var gDebuggee;
5 var gClient;
6 var gThreadClient;
7
8 // Test that closures can be inspected.
9
10 function run_test()
11 {
12 initTestDebuggerServer();
13 gDebuggee = addTestGlobal("test-closures");
14
15 gClient = new DebuggerClient(DebuggerServer.connectPipe());
16 gClient.connect(function() {
17 attachTestTabAndResume(gClient, "test-closures", function(aResponse, aTabClient, aThreadClient) {
18 gThreadClient = aThreadClient;
19 test_object_grip();
20 });
21 });
22 do_test_pending();
23 }
24
25 function test_object_grip()
26 {
27 gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
28 let person = aPacket.frame.environment.bindings.variables.person;
29
30 do_check_eq(person.value.class, "Object");
31
32 let personClient = gThreadClient.pauseGrip(person.value);
33 personClient.getPrototypeAndProperties(aResponse => {
34 do_check_eq(aResponse.ownProperties.getName.value.class, "Function");
35
36 do_check_eq(aResponse.ownProperties.getAge.value.class, "Function");
37
38 do_check_eq(aResponse.ownProperties.getFoo.value.class, "Function");
39
40 let getNameClient = gThreadClient.pauseGrip(aResponse.ownProperties.getName.value);
41 let getAgeClient = gThreadClient.pauseGrip(aResponse.ownProperties.getAge.value);
42 let getFooClient = gThreadClient.pauseGrip(aResponse.ownProperties.getFoo.value);
43 getNameClient.getScope(aResponse => {
44 do_check_eq(aResponse.scope.bindings.arguments[0].name.value, "Bob");
45
46 getAgeClient.getScope(aResponse => {
47 do_check_eq(aResponse.scope.bindings.arguments[1].age.value, 58);
48
49 getFooClient.getScope(aResponse => {
50 do_check_eq(aResponse.scope.bindings.variables.foo.value, 10);
51
52 gThreadClient.resume(() => finishClient(gClient));
53 });
54 });
55 });
56 });
57
58 });
59
60 gDebuggee.eval("(" + function() {
61 var PersonFactory = function(name, age) {
62 var foo = 10;
63 return {
64 getName: function() { return name; },
65 getAge: function() { return age; },
66 getFoo: function() { foo = Date.now(); return foo; }
67 };
68 };
69 var person = new PersonFactory("Bob", 58);
70 debugger;
71 } + ")()");
72 }

mercurial