test_objectgrips-04.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.getPrototypeAndProperties(function (aResponse) {
  37. do_check_eq(aResponse.ownProperties.x.configurable, true);
  38. do_check_eq(aResponse.ownProperties.x.enumerable, true);
  39. do_check_eq(aResponse.ownProperties.x.writable, true);
  40. do_check_eq(aResponse.ownProperties.x.value, 10);
  41. do_check_eq(aResponse.ownProperties.y.configurable, true);
  42. do_check_eq(aResponse.ownProperties.y.enumerable, true);
  43. do_check_eq(aResponse.ownProperties.y.writable, true);
  44. do_check_eq(aResponse.ownProperties.y.value, "kaiju");
  45. do_check_eq(aResponse.ownProperties.a.configurable, true);
  46. do_check_eq(aResponse.ownProperties.a.enumerable, true);
  47. do_check_eq(aResponse.ownProperties.a.get.type, "object");
  48. do_check_eq(aResponse.ownProperties.a.get.class, "Function");
  49. do_check_eq(aResponse.ownProperties.a.set.type, "undefined");
  50. do_check_true(aResponse.prototype != undefined);
  51. let protoClient = gThreadClient.pauseGrip(aResponse.prototype);
  52. protoClient.getOwnPropertyNames(function (aResponse) {
  53. do_check_true(aResponse.ownPropertyNames.toString != undefined);
  54. gThreadClient.resume(function () {
  55. gClient.close().then(gCallback);
  56. });
  57. });
  58. });
  59. });
  60. gDebuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
  61. }