browser_dbg_search-autofill-identifier.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. * Tests that Debugger Search uses the identifier under cursor if nothing is
  6. * selected or manually passed and searching using certain operators.
  7. */
  8. "use strict";
  9. function test() {
  10. const TAB_URL = EXAMPLE_URL + "doc_function-search.html";
  11. let options = {
  12. source: EXAMPLE_URL + "code_function-search-01.js",
  13. line: 1
  14. };
  15. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  16. let Debugger = aPanel.panelWin;
  17. let Editor = Debugger.DebuggerView.editor;
  18. let Filtering = Debugger.DebuggerView.Filtering;
  19. function doSearch(aOperator) {
  20. Editor.dropSelection();
  21. Filtering._doSearch(aOperator);
  22. }
  23. info("Testing with cursor at the beginning of the file...");
  24. doSearch();
  25. is(Filtering._searchbox.value, "",
  26. "The searchbox value should not be auto-filled when searching for files.");
  27. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  28. "The searchbox contents should not be selected");
  29. is(Editor.getSelection(), "",
  30. "The selection in the editor should be empty.");
  31. doSearch("!");
  32. is(Filtering._searchbox.value, "!",
  33. "The searchbox value should not be auto-filled when searching across all files.");
  34. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  35. "The searchbox contents should not be selected");
  36. is(Editor.getSelection(), "",
  37. "The selection in the editor should be empty.");
  38. doSearch("@");
  39. is(Filtering._searchbox.value, "@",
  40. "The searchbox value should not be auto-filled when searching for functions.");
  41. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  42. "The searchbox contents should not be selected");
  43. is(Editor.getSelection(), "",
  44. "The selection in the editor should be empty.");
  45. doSearch("#");
  46. is(Filtering._searchbox.value, "#",
  47. "The searchbox value should not be auto-filled when searching inside a file.");
  48. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  49. "The searchbox contents should not be selected");
  50. is(Editor.getSelection(), "",
  51. "The selection in the editor should be empty.");
  52. doSearch(":");
  53. is(Filtering._searchbox.value, ":",
  54. "The searchbox value should not be auto-filled when searching for a line.");
  55. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  56. "The searchbox contents should not be selected");
  57. is(Editor.getSelection(), "",
  58. "The selection in the editor should be empty.");
  59. doSearch("*");
  60. is(Filtering._searchbox.value, "*",
  61. "The searchbox value should not be auto-filled when searching for variables.");
  62. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  63. "The searchbox contents should not be selected");
  64. is(Editor.getSelection(), "",
  65. "The selection in the editor should be empty.");
  66. Editor.setCursor({ line: 7, ch: 0});
  67. info("Testing with cursor at line 8 and char 1...");
  68. doSearch();
  69. is(Filtering._searchbox.value, "",
  70. "The searchbox value should not be auto-filled when searching for files.");
  71. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  72. "The searchbox contents should not be selected");
  73. is(Editor.getSelection(), "",
  74. "The selection in the editor should be empty.");
  75. doSearch("!");
  76. is(Filtering._searchbox.value, "!test",
  77. "The searchbox value was incorrect when searching across all files.");
  78. is(Filtering._searchbox.selectionStart, 1,
  79. "The searchbox operator should not be selected");
  80. is(Filtering._searchbox.selectionEnd, 5,
  81. "The searchbox contents should be selected");
  82. is(Editor.getSelection(), "",
  83. "The selection in the editor should be empty.");
  84. doSearch("@");
  85. is(Filtering._searchbox.value, "@test",
  86. "The searchbox value was incorrect when searching for functions.");
  87. is(Filtering._searchbox.selectionStart, 1,
  88. "The searchbox operator should not be selected");
  89. is(Filtering._searchbox.selectionEnd, 5,
  90. "The searchbox contents should be selected");
  91. is(Editor.getSelection(), "",
  92. "The selection in the editor should be empty.");
  93. doSearch("#");
  94. is(Filtering._searchbox.value, "#test",
  95. "The searchbox value should be auto-filled when searching inside a file.");
  96. is(Filtering._searchbox.selectionStart, 1,
  97. "The searchbox operator should not be selected");
  98. is(Filtering._searchbox.selectionEnd, 5,
  99. "The searchbox contents should be selected");
  100. is(Editor.getSelection(), "test",
  101. "The selection in the editor should be 'test'.");
  102. doSearch(":");
  103. is(Filtering._searchbox.value, ":",
  104. "The searchbox value should not be auto-filled when searching for a line.");
  105. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  106. "The searchbox contents should not be selected");
  107. is(Editor.getSelection(), "",
  108. "The selection in the editor should be empty.");
  109. doSearch("*");
  110. is(Filtering._searchbox.value, "*",
  111. "The searchbox value should not be auto-filled when searching for variables.");
  112. is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
  113. "The searchbox contents should not be selected");
  114. is(Editor.getSelection(), "",
  115. "The selection in the editor should be empty.");
  116. closeDebuggerAndFinish(aPanel);
  117. });
  118. }