Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 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";
10 function test() {
11 const TAB_URL = EXAMPLE_URL + "doc_function-search.html";
13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
14 let Source = 'code_function-search-01.js';
15 let Debugger = aPanel.panelWin;
16 let Editor = Debugger.DebuggerView.editor;
17 let Filtering = Debugger.DebuggerView.Filtering;
19 function doSearch(aOperator) {
20 Editor.dropSelection();
21 Filtering._doSearch(aOperator);
22 }
24 waitForSourceShown(aPanel, Source).then(() => {
25 info("Testing with cursor at the beginning of the file...");
27 doSearch();
28 is(Filtering._searchbox.value, "",
29 "The searchbox value should not be auto-filled when searching for files.");
30 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
31 "The searchbox contents should not be selected");
32 is(Editor.getSelection(), "",
33 "The selection in the editor should be empty.");
35 doSearch("!");
36 is(Filtering._searchbox.value, "!",
37 "The searchbox value should not be auto-filled when searching across all files.");
38 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
39 "The searchbox contents should not be selected");
40 is(Editor.getSelection(), "",
41 "The selection in the editor should be empty.");
43 doSearch("@");
44 is(Filtering._searchbox.value, "@",
45 "The searchbox value should not be auto-filled when searching for functions.");
46 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
47 "The searchbox contents should not be selected");
48 is(Editor.getSelection(), "",
49 "The selection in the editor should be empty.");
51 doSearch("#");
52 is(Filtering._searchbox.value, "#",
53 "The searchbox value should not be auto-filled when searching inside a file.");
54 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
55 "The searchbox contents should not be selected");
56 is(Editor.getSelection(), "",
57 "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 a line.");
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.");
67 doSearch("*");
68 is(Filtering._searchbox.value, "*",
69 "The searchbox value should not be auto-filled when searching for variables.");
70 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
71 "The searchbox contents should not be selected");
72 is(Editor.getSelection(), "",
73 "The selection in the editor should be empty.");
75 Editor.setCursor({ line: 7, ch: 0});
76 info("Testing with cursor at line 8 and char 1...");
78 doSearch();
79 is(Filtering._searchbox.value, "",
80 "The searchbox value should not be auto-filled when searching for files.");
81 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
82 "The searchbox contents should not be selected");
83 is(Editor.getSelection(), "",
84 "The selection in the editor should be empty.");
86 doSearch("!");
87 is(Filtering._searchbox.value, "!test",
88 "The searchbox value was incorrect when searching across all files.");
89 is(Filtering._searchbox.selectionStart, 1,
90 "The searchbox operator should not be selected");
91 is(Filtering._searchbox.selectionEnd, 5,
92 "The searchbox contents should be selected");
93 is(Editor.getSelection(), "",
94 "The selection in the editor should be empty.");
96 doSearch("@");
97 is(Filtering._searchbox.value, "@test",
98 "The searchbox value was incorrect when searching for functions.");
99 is(Filtering._searchbox.selectionStart, 1,
100 "The searchbox operator should not be selected");
101 is(Filtering._searchbox.selectionEnd, 5,
102 "The searchbox contents should be selected");
103 is(Editor.getSelection(), "",
104 "The selection in the editor should be empty.");
106 doSearch("#");
107 is(Filtering._searchbox.value, "#test",
108 "The searchbox value should be auto-filled when searching inside a file.");
109 is(Filtering._searchbox.selectionStart, 1,
110 "The searchbox operator should not be selected");
111 is(Filtering._searchbox.selectionEnd, 5,
112 "The searchbox contents should be selected");
113 is(Editor.getSelection(), "test",
114 "The selection in the editor should be 'test'.");
116 doSearch(":");
117 is(Filtering._searchbox.value, ":",
118 "The searchbox value should not be auto-filled when searching for a line.");
119 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
120 "The searchbox contents should not be selected");
121 is(Editor.getSelection(), "",
122 "The selection in the editor should be empty.");
124 doSearch("*");
125 is(Filtering._searchbox.value, "*",
126 "The searchbox value should not be auto-filled when searching for variables.");
127 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
128 "The searchbox contents should not be selected");
129 is(Editor.getSelection(), "",
130 "The selection in the editor should be empty.");
132 closeDebuggerAndFinish(aPanel);
133 });
134 });
135 };