browser_canvas-frontend-call-stack-03.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests if the a function call's stack can be shown/hidden by double-clicking
  5. * on a function call item.
  6. */
  7. function* ifTestingSupported() {
  8. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
  9. let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  10. yield reload(target);
  11. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  12. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  13. SnapshotsListView._onRecordButtonClick();
  14. yield promise.all([recordingFinished, callListPopulated]);
  15. let callItem = CallsListView.getItemAtIndex(2);
  16. let view = $(".call-item-view", callItem.target);
  17. let contents = $(".call-item-contents", callItem.target);
  18. is(view.hasAttribute("call-stack-populated"), false,
  19. "The call item's view should not have the stack populated yet.");
  20. is(view.hasAttribute("call-stack-expanded"), false,
  21. "The call item's view should not have the stack populated yet.");
  22. is($(".call-item-stack", callItem.target), null,
  23. "There should be no stack container available yet for the draw call.");
  24. let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
  25. EventUtils.sendMouseEvent({ type: "dblclick" }, contents, window);
  26. yield callStackDisplayed;
  27. is(view.hasAttribute("call-stack-populated"), true,
  28. "The call item's view should have the stack populated now.");
  29. is(view.getAttribute("call-stack-expanded"), "true",
  30. "The call item's view should have the stack expanded now.");
  31. isnot($(".call-item-stack", callItem.target), null,
  32. "There should be a stack container available now for the draw call.");
  33. is($(".call-item-stack", callItem.target).hidden, false,
  34. "The stack container should now be visible.");
  35. // We may have more than 4 functions, depending on whether async
  36. // stacks are available.
  37. ok($all(".call-item-stack-fn", callItem.target).length >= 4,
  38. "There should be at least 4 functions on the stack for the draw call.");
  39. EventUtils.sendMouseEvent({ type: "dblclick" }, contents, window);
  40. is(view.hasAttribute("call-stack-populated"), true,
  41. "The call item's view should still have the stack populated.");
  42. is(view.getAttribute("call-stack-expanded"), "false",
  43. "The call item's view should not have the stack expanded anymore.");
  44. isnot($(".call-item-stack", callItem.target), null,
  45. "There should still be a stack container available for the draw call.");
  46. is($(".call-item-stack", callItem.target).hidden, true,
  47. "The stack container should now be hidden.");
  48. // We may have more than 4 functions, depending on whether async
  49. // stacks are available.
  50. ok($all(".call-item-stack-fn", callItem.target).length >= 4,
  51. "There should still be at least 4 functions on the stack for the draw call.");
  52. yield teardown(panel);
  53. finish();
  54. }