test_objectgrips-02.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. var gDebuggee;
  4. var gClient;
  5. var gThreadClient;
  6. var gCallback;
  7. function run_test()
  8. {
  9. run_test_with_server(DebuggerServer, function () {
  10. run_test_with_server(WorkerDebuggerServer, do_test_finished);
  11. });
  12. do_test_pending();
  13. }
  14. function run_test_with_server(aServer, aCallback)
  15. {
  16. gCallback = aCallback;
  17. initTestDebuggerServer(aServer);
  18. gDebuggee = addTestGlobal("test-grips", aServer);
  19. gDebuggee.eval(function stopMe(arg1) {
  20. debugger;
  21. }.toString());
  22. gClient = new DebuggerClient(aServer.connectPipe());
  23. gClient.connect().then(function () {
  24. attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
  25. gThreadClient = aThreadClient;
  26. test_object_grip();
  27. });
  28. });
  29. }
  30. function test_object_grip()
  31. {
  32. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  33. let args = aPacket.frame.arguments;
  34. do_check_eq(args[0].class, "Object");
  35. let objClient = gThreadClient.pauseGrip(args[0]);
  36. objClient.getPrototype(function (aResponse) {
  37. do_check_true(aResponse.prototype != undefined);
  38. let protoClient = gThreadClient.pauseGrip(aResponse.prototype);
  39. protoClient.getOwnPropertyNames(function (aResponse) {
  40. do_check_eq(aResponse.ownPropertyNames.length, 2);
  41. do_check_eq(aResponse.ownPropertyNames[0], "b");
  42. do_check_eq(aResponse.ownPropertyNames[1], "c");
  43. gThreadClient.resume(function () {
  44. gClient.close().then(gCallback);
  45. });
  46. });
  47. });
  48. });
  49. gDebuggee.eval(function Constr() {
  50. this.a = 1;
  51. }.toString());
  52. gDebuggee.eval("Constr.prototype = { b: true, c: 'foo' }; var o = new Constr(); stopMe(o)");
  53. }