browser_canvas-frontend-call-stack-01.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 is properly displayed in the UI.
  5. */
  6. // Force the old debugger UI since it's directly used (see Bug 1301705)
  7. Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
  8. registerCleanupFunction(function* () {
  9. Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
  10. });
  11. function* ifTestingSupported() {
  12. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
  13. let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  14. yield reload(target);
  15. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  16. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  17. SnapshotsListView._onRecordButtonClick();
  18. yield promise.all([recordingFinished, callListPopulated]);
  19. let callItem = CallsListView.getItemAtIndex(2);
  20. let locationLink = $(".call-item-location", callItem.target);
  21. is($(".call-item-stack", callItem.target), null,
  22. "There should be no stack container available yet for the draw call.");
  23. let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
  24. EventUtils.sendMouseEvent({ type: "mousedown" }, locationLink, window);
  25. yield callStackDisplayed;
  26. isnot($(".call-item-stack", callItem.target), null,
  27. "There should be a stack container available now for the draw call.");
  28. // We may have more than 4 functions, depending on whether async
  29. // stacks are available.
  30. ok($all(".call-item-stack-fn", callItem.target).length >= 4,
  31. "There should be at least 4 functions on the stack for the draw call.");
  32. ok($all(".call-item-stack-fn-name", callItem.target)[0].getAttribute("value")
  33. .includes("C()"),
  34. "The first function on the stack has the correct name.");
  35. ok($all(".call-item-stack-fn-name", callItem.target)[1].getAttribute("value")
  36. .includes("B()"),
  37. "The second function on the stack has the correct name.");
  38. ok($all(".call-item-stack-fn-name", callItem.target)[2].getAttribute("value")
  39. .includes("A()"),
  40. "The third function on the stack has the correct name.");
  41. ok($all(".call-item-stack-fn-name", callItem.target)[3].getAttribute("value")
  42. .includes("drawRect()"),
  43. "The fourth function on the stack has the correct name.");
  44. is($all(".call-item-stack-fn-location", callItem.target)[0].getAttribute("value"),
  45. "doc_simple-canvas-deep-stack.html:26",
  46. "The first function on the stack has the correct location.");
  47. is($all(".call-item-stack-fn-location", callItem.target)[1].getAttribute("value"),
  48. "doc_simple-canvas-deep-stack.html:28",
  49. "The second function on the stack has the correct location.");
  50. is($all(".call-item-stack-fn-location", callItem.target)[2].getAttribute("value"),
  51. "doc_simple-canvas-deep-stack.html:30",
  52. "The third function on the stack has the correct location.");
  53. is($all(".call-item-stack-fn-location", callItem.target)[3].getAttribute("value"),
  54. "doc_simple-canvas-deep-stack.html:35",
  55. "The fourth function on the stack has the correct location.");
  56. let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
  57. EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-stack-fn-location", callItem.target));
  58. yield jumpedToSource;
  59. let toolbox = yield gDevTools.getToolbox(target);
  60. let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
  61. is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL),
  62. "The expected source was shown in the debugger.");
  63. is(view.editor.getCursor().line, 25,
  64. "The expected source line is highlighted in the debugger.");
  65. yield teardown(panel);
  66. finish();
  67. }