|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the selection is dropped for line and token searches, after |
|
6 * pressing backspace enough times. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gEditor, gSources, gSearchBox; |
|
13 |
|
14 function test() { |
|
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
16 gTab = aTab; |
|
17 gDebuggee = aDebuggee; |
|
18 gPanel = aPanel; |
|
19 gDebugger = gPanel.panelWin; |
|
20 gEditor = gDebugger.DebuggerView.editor; |
|
21 gSources = gDebugger.DebuggerView.Sources; |
|
22 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
|
23 |
|
24 waitForSourceShown(gPanel, "-01.js") |
|
25 .then(testLineSearch) |
|
26 .then(testTokenSearch) |
|
27 .then(() => closeDebuggerAndFinish(gPanel)) |
|
28 .then(null, aError => { |
|
29 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
30 }); |
|
31 }); |
|
32 } |
|
33 |
|
34 function testLineSearch() { |
|
35 setText(gSearchBox, ":42"); |
|
36 ok(isCaretPos(gPanel, 7), |
|
37 "The editor caret position appears to be correct (1.1)."); |
|
38 ok(isEditorSel(gPanel, [160, 160]), |
|
39 "The editor selection appears to be correct (1.1)."); |
|
40 is(gEditor.getSelection(), "", |
|
41 "The editor selected text appears to be correct (1.1)."); |
|
42 |
|
43 backspaceText(gSearchBox, 1); |
|
44 ok(isCaretPos(gPanel, 4), |
|
45 "The editor caret position appears to be correct (1.2)."); |
|
46 ok(isEditorSel(gPanel, [110, 110]), |
|
47 "The editor selection appears to be correct (1.2)."); |
|
48 is(gEditor.getSelection(), "", |
|
49 "The editor selected text appears to be correct (1.2)."); |
|
50 |
|
51 backspaceText(gSearchBox, 1); |
|
52 ok(isCaretPos(gPanel, 4), |
|
53 "The editor caret position appears to be correct (1.3)."); |
|
54 ok(isEditorSel(gPanel, [110, 110]), |
|
55 "The editor selection appears to be correct (1.3)."); |
|
56 is(gEditor.getSelection(), "", |
|
57 "The editor selected text appears to be correct (1.3)."); |
|
58 |
|
59 setText(gSearchBox, ":4"); |
|
60 ok(isCaretPos(gPanel, 4), |
|
61 "The editor caret position appears to be correct (1.4)."); |
|
62 ok(isEditorSel(gPanel, [110, 110]), |
|
63 "The editor selection appears to be correct (1.4)."); |
|
64 is(gEditor.getSelection(), "", |
|
65 "The editor selected text appears to be correct (1.4)."); |
|
66 |
|
67 gSearchBox.select(); |
|
68 backspaceText(gSearchBox, 1); |
|
69 ok(isCaretPos(gPanel, 4), |
|
70 "The editor caret position appears to be correct (1.5)."); |
|
71 ok(isEditorSel(gPanel, [110, 110]), |
|
72 "The editor selection appears to be correct (1.5)."); |
|
73 is(gEditor.getSelection(), "", |
|
74 "The editor selected text appears to be correct (1.5)."); |
|
75 is(gSearchBox.value, "", |
|
76 "The searchbox should have been cleared."); |
|
77 } |
|
78 |
|
79 function testTokenSearch() { |
|
80 setText(gSearchBox, "#;\""); |
|
81 ok(isCaretPos(gPanel, 5, 23), |
|
82 "The editor caret position appears to be correct (2.1)."); |
|
83 ok(isEditorSel(gPanel, [153, 155]), |
|
84 "The editor selection appears to be correct (2.1)."); |
|
85 is(gEditor.getSelection(), ";\"", |
|
86 "The editor selected text appears to be correct (2.1)."); |
|
87 |
|
88 backspaceText(gSearchBox, 1); |
|
89 ok(isCaretPos(gPanel, 5, 22), |
|
90 "The editor caret position appears to be correct (2.2)."); |
|
91 ok(isEditorSel(gPanel, [153, 154]), |
|
92 "The editor selection appears to be correct (2.2)."); |
|
93 is(gEditor.getSelection(), ";", |
|
94 "The editor selected text appears to be correct (2.2)."); |
|
95 |
|
96 backspaceText(gSearchBox, 1); |
|
97 ok(isCaretPos(gPanel, 5, 22), |
|
98 "The editor caret position appears to be correct (2.3)."); |
|
99 ok(isEditorSel(gPanel, [154, 154]), |
|
100 "The editor selection appears to be correct (2.3)."); |
|
101 is(gEditor.getSelection(), "", |
|
102 "The editor selected text appears to be correct (2.3)."); |
|
103 |
|
104 setText(gSearchBox, "#;"); |
|
105 ok(isCaretPos(gPanel, 5, 22), |
|
106 "The editor caret position appears to be correct (2.4)."); |
|
107 ok(isEditorSel(gPanel, [153, 154]), |
|
108 "The editor selection appears to be correct (2.4)."); |
|
109 is(gEditor.getSelection(), ";", |
|
110 "The editor selected text appears to be correct (2.4)."); |
|
111 |
|
112 gSearchBox.select(); |
|
113 backspaceText(gSearchBox, 1); |
|
114 ok(isCaretPos(gPanel, 5, 22), |
|
115 "The editor caret position appears to be correct (2.5)."); |
|
116 ok(isEditorSel(gPanel, [154, 154]), |
|
117 "The editor selection appears to be correct (2.5)."); |
|
118 is(gEditor.getSelection(), "", |
|
119 "The editor selected text appears to be correct (2.5)."); |
|
120 is(gSearchBox.value, "", |
|
121 "The searchbox should have been cleared."); |
|
122 } |
|
123 |
|
124 registerCleanupFunction(function() { |
|
125 gTab = null; |
|
126 gDebuggee = null; |
|
127 gPanel = null; |
|
128 gDebugger = null; |
|
129 gEditor = null; |
|
130 gSources = null; |
|
131 gSearchBox = null; |
|
132 }); |