browser_dbg_stack-contextmenu-01.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 that the copy contextmenu has been added to the stack frames view.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
  8. let gTab, gPanel, gDebugger;
  9. let gFrames, gContextMenu;
  10. function test() {
  11. let options = {
  12. source: TAB_URL,
  13. line: 1
  14. };
  15. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  16. gTab = aTab;
  17. gPanel = aPanel;
  18. gDebugger = gPanel.panelWin;
  19. gFrames = gDebugger.DebuggerView.StackFrames;
  20. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED)
  21. .then(performTest);
  22. callInTab(gTab, "simpleCall");
  23. });
  24. }
  25. function performTest() {
  26. gContextMenu = gDebugger.document.getElementById("stackFramesContextMenu");
  27. is(gDebugger.gThreadClient.state, "paused",
  28. "Should only be getting stack frames while paused.");
  29. is(gFrames.itemCount, 1,
  30. "Should have only one frame.");
  31. ok(gContextMenu, "The stack frame's context menupopup is available.");
  32. once(gContextMenu, "popupshown").then(testContextMenu);
  33. EventUtils.synthesizeMouseAtCenter(gFrames.getItemAtIndex(0).prebuiltNode, {type: "contextmenu", button: 2}, gDebugger);
  34. }
  35. function testContextMenu() {
  36. let document = gDebugger.document;
  37. ok(document.getElementById("copyStackMenuItem"),
  38. "#copyStackMenuItem found.");
  39. gContextMenu.hidePopup();
  40. resumeDebuggerThenCloseAndFinish(gPanel);
  41. }
  42. registerCleanupFunction(function () {
  43. gTab = null;
  44. gPanel = null;
  45. gDebugger = null;
  46. gFrames = null;
  47. gContextMenu = null;
  48. });