browser_dbg_blackboxing-01.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 if we black box a source and then refresh, it is still black boxed.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_binary_search.html";
  8. var gTab, gPanel, gDebugger;
  9. function test() {
  10. let options = {
  11. source: EXAMPLE_URL + "code_binary_search.coffee",
  12. line: 1
  13. };
  14. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  15. gTab = aTab;
  16. gPanel = aPanel;
  17. gDebugger = gPanel.panelWin;
  18. testBlackBoxSource()
  19. .then(testBlackBoxReload)
  20. .then(() => closeDebuggerAndFinish(gPanel))
  21. .then(null, aError => {
  22. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  23. });
  24. });
  25. }
  26. function testBlackBoxSource() {
  27. const bbButton = getBlackBoxButton(gPanel);
  28. ok(!bbButton.checked, "Should not be black boxed by default");
  29. return toggleBlackBoxing(gPanel).then(source => {
  30. ok(source.isBlackBoxed, "The source should be black boxed now.");
  31. ok(bbButton.checked, "The checkbox should no longer be checked.");
  32. });
  33. }
  34. function testBlackBoxReload() {
  35. return reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(() => {
  36. const bbButton = getBlackBoxButton(gPanel);
  37. const selectedSource = getSelectedSourceElement(gPanel);
  38. ok(bbButton.checked, "Should still be black boxed.");
  39. ok(selectedSource.classList.contains("black-boxed"),
  40. "'black-boxed' class should still be applied");
  41. });
  42. }
  43. registerCleanupFunction(function () {
  44. gTab = null;
  45. gPanel = null;
  46. gDebugger = null;
  47. });