browser_dbg_blackboxing-04.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 we get a stack frame for each black boxed source, not a single one
  6. * for all of them.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
  9. const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js";
  10. var gTab, gPanel, gDebugger;
  11. var gFrames, gSources;
  12. function test() {
  13. let options = {
  14. source: BLACKBOXME_URL,
  15. line: 1
  16. };
  17. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  18. gTab = aTab;
  19. gPanel = aPanel;
  20. gDebugger = gPanel.panelWin;
  21. gFrames = gDebugger.DebuggerView.StackFrames;
  22. gSources = gDebugger.DebuggerView.Sources;
  23. blackBoxSources()
  24. .then(testBlackBoxStack)
  25. .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
  26. .then(null, aError => {
  27. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  28. });
  29. });
  30. }
  31. function blackBoxSources() {
  32. let finished = waitForThreadEvents(gPanel, "blackboxchange", 3);
  33. toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_one.js"));
  34. toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_two.js"));
  35. toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_three.js"));
  36. return finished;
  37. }
  38. function testBlackBoxStack() {
  39. let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => {
  40. is(gFrames.itemCount, 4,
  41. "Should get 4 frames (one -> two -> three -> doDebuggerStatement).");
  42. is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3,
  43. "And 'one', 'two', and 'three' should each have their own black boxed frame.");
  44. });
  45. callInTab(gTab, "one");
  46. return finished;
  47. }
  48. registerCleanupFunction(function () {
  49. gTab = null;
  50. gPanel = null;
  51. gDebugger = null;
  52. gFrames = null;
  53. gSources = null;
  54. });