browser_dbg_variables-view-popup-16.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. requestLongerTimeout(2);
  5. /**
  6. * Tests if opening the variables inspection popup preserves the highlighting
  7. * associated with the currently debugged line.
  8. */
  9. const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
  10. function test() {
  11. Task.spawn(function* () {
  12. let options = {
  13. source: TAB_URL,
  14. line: 1
  15. };
  16. let [tab,, panel] = yield initDebugger(TAB_URL, options);
  17. let win = panel.panelWin;
  18. let events = win.EVENTS;
  19. let editor = win.DebuggerView.editor;
  20. let frames = win.DebuggerView.StackFrames;
  21. let variables = win.DebuggerView.Variables;
  22. let bubble = win.DebuggerView.VariableBubble;
  23. let tooltip = bubble._tooltip.panel;
  24. function checkView(selectedFrame, caretLine, debugLine = caretLine) {
  25. let deferred = promise.defer();
  26. is(win.gThreadClient.state, "paused",
  27. "Should only be getting stack frames while paused.");
  28. is(frames.itemCount, 25,
  29. "Should have 25 frames.");
  30. is(frames.selectedDepth, selectedFrame,
  31. "The correct frame is selected in the widget.");
  32. ok(isCaretPos(panel, caretLine),
  33. "Editor caret location is correct.");
  34. // The editor's debug location takes a tick to update.
  35. executeSoon(() => {
  36. ok(isCaretPos(panel, caretLine), "Editor caret location is still correct.");
  37. ok(isDebugPos(panel, debugLine), "Editor debug location is correct.");
  38. deferred.resolve();
  39. });
  40. return deferred.promise;
  41. }
  42. function expandGlobalScope() {
  43. let globalScope = variables.getScopeAtIndex(2);
  44. is(globalScope.expanded, false,
  45. "The globalScope should not be expanded yet.");
  46. let finished = waitForDebuggerEvents(panel, events.FETCHED_VARIABLES);
  47. globalScope.expand();
  48. return finished;
  49. }
  50. let onCaretAndScopes = waitForCaretAndScopes(panel, 26);
  51. callInTab(tab, "recurse");
  52. yield onCaretAndScopes;
  53. yield checkView(0, 26);
  54. yield expandGlobalScope();
  55. yield checkView(0, 26);
  56. // Inspect variable in topmost frame.
  57. yield openVarPopup(panel, { line: 26, ch: 11 });
  58. yield checkView(0, 26);
  59. yield resumeDebuggerThenCloseAndFinish(panel);
  60. });
  61. }