michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that Debugger Search uses the identifier under cursor if nothing is michael@0: * selected or manually passed and searching using certain operators. michael@0: */ michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: const TAB_URL = EXAMPLE_URL + "doc_function-search.html"; michael@0: michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: let Source = 'code_function-search-01.js'; michael@0: let Debugger = aPanel.panelWin; michael@0: let Editor = Debugger.DebuggerView.editor; michael@0: let Filtering = Debugger.DebuggerView.Filtering; michael@0: michael@0: function doSearch(aOperator) { michael@0: Editor.dropSelection(); michael@0: Filtering._doSearch(aOperator); michael@0: } michael@0: michael@0: waitForSourceShown(aPanel, Source).then(() => { michael@0: info("Testing with cursor at the beginning of the file..."); michael@0: michael@0: doSearch(); michael@0: is(Filtering._searchbox.value, "", michael@0: "The searchbox value should not be auto-filled when searching for files."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("!"); michael@0: is(Filtering._searchbox.value, "!", michael@0: "The searchbox value should not be auto-filled when searching across all files."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("@"); michael@0: is(Filtering._searchbox.value, "@", michael@0: "The searchbox value should not be auto-filled when searching for functions."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("#"); michael@0: is(Filtering._searchbox.value, "#", michael@0: "The searchbox value should not be auto-filled when searching inside a file."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch(":"); michael@0: is(Filtering._searchbox.value, ":", michael@0: "The searchbox value should not be auto-filled when searching for a line."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("*"); michael@0: is(Filtering._searchbox.value, "*", michael@0: "The searchbox value should not be auto-filled when searching for variables."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: Editor.setCursor({ line: 7, ch: 0}); michael@0: info("Testing with cursor at line 8 and char 1..."); michael@0: michael@0: doSearch(); michael@0: is(Filtering._searchbox.value, "", michael@0: "The searchbox value should not be auto-filled when searching for files."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("!"); michael@0: is(Filtering._searchbox.value, "!test", michael@0: "The searchbox value was incorrect when searching across all files."); michael@0: is(Filtering._searchbox.selectionStart, 1, michael@0: "The searchbox operator should not be selected"); michael@0: is(Filtering._searchbox.selectionEnd, 5, michael@0: "The searchbox contents should be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("@"); michael@0: is(Filtering._searchbox.value, "@test", michael@0: "The searchbox value was incorrect when searching for functions."); michael@0: is(Filtering._searchbox.selectionStart, 1, michael@0: "The searchbox operator should not be selected"); michael@0: is(Filtering._searchbox.selectionEnd, 5, michael@0: "The searchbox contents should be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("#"); michael@0: is(Filtering._searchbox.value, "#test", michael@0: "The searchbox value should be auto-filled when searching inside a file."); michael@0: is(Filtering._searchbox.selectionStart, 1, michael@0: "The searchbox operator should not be selected"); michael@0: is(Filtering._searchbox.selectionEnd, 5, michael@0: "The searchbox contents should be selected"); michael@0: is(Editor.getSelection(), "test", michael@0: "The selection in the editor should be 'test'."); michael@0: michael@0: doSearch(":"); michael@0: is(Filtering._searchbox.value, ":", michael@0: "The searchbox value should not be auto-filled when searching for a line."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: doSearch("*"); michael@0: is(Filtering._searchbox.value, "*", michael@0: "The searchbox value should not be auto-filled when searching for variables."); michael@0: is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd, michael@0: "The searchbox contents should not be selected"); michael@0: is(Editor.getSelection(), "", michael@0: "The selection in the editor should be empty."); michael@0: michael@0: closeDebuggerAndFinish(aPanel); michael@0: }); michael@0: }); michael@0: };