browser_canvas-frontend-call-stack-02.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * and jumping to source in the debugger for the topmost call item works.
  6. */
  7. // Force the old debugger UI since it's directly used (see Bug 1301705)
  8. Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
  9. registerCleanupFunction(function* () {
  10. Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
  11. });
  12. function* ifTestingSupported() {
  13. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
  14. let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  15. yield reload(target);
  16. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  17. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  18. SnapshotsListView._onRecordButtonClick();
  19. yield promise.all([recordingFinished, callListPopulated]);
  20. let callItem = CallsListView.getItemAtIndex(2);
  21. let locationLink = $(".call-item-location", callItem.target);
  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: "mousedown" }, locationLink, window);
  26. yield callStackDisplayed;
  27. isnot($(".call-item-stack", callItem.target), null,
  28. "There should be a stack container available now for the draw call.");
  29. // We may have more than 4 functions, depending on whether async
  30. // stacks are available.
  31. ok($all(".call-item-stack-fn", callItem.target).length >= 4,
  32. "There should be at least 4 functions on the stack for the draw call.");
  33. let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
  34. EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-location", callItem.target));
  35. yield jumpedToSource;
  36. let toolbox = yield gDevTools.getToolbox(target);
  37. let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
  38. is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL),
  39. "The expected source was shown in the debugger.");
  40. is(view.editor.getCursor().line, 23,
  41. "The expected source line is highlighted in the debugger.");
  42. yield teardown(panel);
  43. finish();
  44. }