test_framebindings-02.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check a frame actor's parent bindings.
  5. */
  6. var gDebuggee;
  7. var gClient;
  8. var gThreadClient;
  9. function run_test()
  10. {
  11. initTestDebuggerServer();
  12. gDebuggee = addTestGlobal("test-stack");
  13. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  14. gClient.connect().then(function () {
  15. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  16. gThreadClient = aThreadClient;
  17. test_pause_frame();
  18. });
  19. });
  20. do_test_pending();
  21. }
  22. function test_pause_frame()
  23. {
  24. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  25. let parentEnv = aPacket.frame.environment.parent;
  26. let bindings = parentEnv.bindings;
  27. let args = bindings.arguments;
  28. let vars = bindings.variables;
  29. do_check_neq(parentEnv, undefined);
  30. do_check_eq(args.length, 0);
  31. do_check_eq(vars.stopMe.value.type, "object");
  32. do_check_eq(vars.stopMe.value.class, "Function");
  33. do_check_true(!!vars.stopMe.value.actor);
  34. // Skip the global lexical scope.
  35. parentEnv = parentEnv.parent.parent;
  36. do_check_neq(parentEnv, undefined);
  37. let objClient = gThreadClient.pauseGrip(parentEnv.object);
  38. objClient.getPrototypeAndProperties(function (aResponse) {
  39. do_check_eq(aResponse.ownProperties.Object.value.type, "object");
  40. do_check_eq(aResponse.ownProperties.Object.value.class, "Function");
  41. do_check_true(!!aResponse.ownProperties.Object.value.actor);
  42. gThreadClient.resume(function () {
  43. finishClient(gClient);
  44. });
  45. });
  46. });
  47. gDebuggee.eval("(" + function () {
  48. function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) {
  49. var a = 1;
  50. var b = true;
  51. var c = { a: "a" };
  52. debugger;
  53. }
  54. stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
  55. } + ")()");
  56. }