browser_dbg_break-on-next-console.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /**
  5. * Test if 'break on next' functionality works from executions
  6. * in content triggered by the console in the toolbox.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_script-eval.html";
  9. function test() {
  10. let gTab, gPanel, gDebugger;
  11. let gSources, gBreakpoints, gTarget, gResumeButton, gResumeKey, gThreadClient;
  12. let options = {
  13. source: EXAMPLE_URL + "code_script-eval.js",
  14. line: 1
  15. };
  16. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  17. gTab = aTab;
  18. gPanel = aPanel;
  19. gDebugger = gPanel.panelWin;
  20. gSources = gDebugger.DebuggerView.Sources;
  21. gTarget = gDebugger.gTarget;
  22. gThreadClient = gDebugger.gThreadClient;
  23. gResumeButton = gDebugger.document.getElementById("resume");
  24. gResumeKey = gDebugger.document.getElementById("resumeKey");
  25. testConsole()
  26. .then(() => closeDebuggerAndFinish(gPanel));
  27. });
  28. let testConsole = Task.async(function* () {
  29. info("Starting testConsole");
  30. let oncePaused = gTarget.once("thread-paused");
  31. EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
  32. let jsterm = yield getSplitConsole(gDevTools.getToolbox(gPanel.target));
  33. let executed = jsterm.execute("1+1");
  34. yield oncePaused;
  35. let updatedFrame = yield waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
  36. let variables = gDebugger.DebuggerView.Variables;
  37. is(variables._store.length, 3, "Correct number of scopes available");
  38. is(variables.getScopeAtIndex(0).name, "With scope [Object]",
  39. "Paused with correct scope (0)");
  40. is(variables.getScopeAtIndex(1).name, "Block scope",
  41. "Paused with correct scope (1)");
  42. is(variables.getScopeAtIndex(2).name, "Global scope [Window]",
  43. "Paused with correct scope (2)");
  44. let onceResumed = gTarget.once("thread-resumed");
  45. EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
  46. yield onceResumed;
  47. yield executed;
  48. });
  49. }