browser_dbg_blackboxing-05.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 a "this source is blackboxed" message is shown when necessary
  6. * and can be properly dismissed.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_binary_search.html";
  9. var gTab, gPanel, gDebugger;
  10. var gDeck;
  11. function test() {
  12. let options = {
  13. source: EXAMPLE_URL + "code_binary_search.coffee",
  14. line: 1
  15. };
  16. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  17. gTab = aTab;
  18. gPanel = aPanel;
  19. gDebugger = gPanel.panelWin;
  20. gDeck = gDebugger.document.getElementById("editor-deck");
  21. testSourceEditorShown();
  22. toggleBlackBoxing(gPanel)
  23. .then(testBlackBoxMessageShown)
  24. .then(clickStopBlackBoxingButton)
  25. .then(testSourceEditorShownAgain)
  26. .then(() => closeDebuggerAndFinish(gPanel))
  27. .then(null, aError => {
  28. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  29. });
  30. });
  31. }
  32. function testSourceEditorShown() {
  33. is(gDeck.selectedIndex, "0",
  34. "The first item in the deck should be selected (the source editor).");
  35. }
  36. function testBlackBoxMessageShown() {
  37. is(gDeck.selectedIndex, "1",
  38. "The second item in the deck should be selected (the black box message).");
  39. }
  40. function clickStopBlackBoxingButton() {
  41. // Give the test a chance to finish before triggering the click event.
  42. executeSoon(() => getEditorBlackboxMessageButton().click());
  43. return waitForDispatch(gPanel, gDebugger.constants.BLACKBOX);
  44. }
  45. function testSourceEditorShownAgain() {
  46. // Wait a tick for the final check to make sure the frontend's click handlers
  47. // have finished.
  48. return new Promise(resolve => {
  49. is(gDeck.selectedIndex, "0",
  50. "The first item in the deck should be selected again (the source editor).");
  51. resolve();
  52. });
  53. }
  54. function getEditorBlackboxMessageButton() {
  55. return gDebugger.document.getElementById("black-boxed-message-button");
  56. }
  57. registerCleanupFunction(function () {
  58. gTab = null;
  59. gPanel = null;
  60. gDebugger = null;
  61. gDeck = null;
  62. });