|
1 /* |
|
2 * Copyright 2012, Mozilla Foundation and contributors |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 'use strict'; |
|
18 // <INJECTED SOURCE:START> |
|
19 |
|
20 // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT |
|
21 // DO NOT EDIT IT DIRECTLY |
|
22 |
|
23 var exports = {}; |
|
24 |
|
25 var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testRemoteXhr.js</p>"; |
|
26 |
|
27 function test() { |
|
28 return Task.spawn(function() { |
|
29 let options = yield helpers.openTab(TEST_URI); |
|
30 yield helpers.openToolbar(options); |
|
31 gcli.addItems(mockCommands.items); |
|
32 |
|
33 yield helpers.runTests(options, exports); |
|
34 |
|
35 gcli.removeItems(mockCommands.items); |
|
36 yield helpers.closeToolbar(options); |
|
37 yield helpers.closeTab(options); |
|
38 }).then(finish, helpers.handleError); |
|
39 } |
|
40 |
|
41 // <INJECTED SOURCE:END> |
|
42 |
|
43 // var assert = require('../testharness/assert'); |
|
44 // var helpers = require('./helpers'); |
|
45 |
|
46 // testRemoteWs and testRemoteXhr are virtually identical. |
|
47 // Changes made here should be made there too. |
|
48 // They are kept separate to save adding complexity to the test system and so |
|
49 // to help us select the test that are available in different environments |
|
50 |
|
51 exports.testRemoteXhr = function(options) { |
|
52 return helpers.audit(options, [ |
|
53 { |
|
54 skipRemainingIf: options.isRemote || options.isNode || options.isFirefox, |
|
55 setup: 'remote ', |
|
56 check: { |
|
57 input: 'remote ', |
|
58 hints: '', |
|
59 markup: 'EEEEEEV', |
|
60 cursor: 7, |
|
61 current: '__command', |
|
62 status: 'ERROR', |
|
63 options: [ ], |
|
64 message: 'Can\'t use \'remote\'.', |
|
65 predictions: [ ], |
|
66 unassigned: [ ], |
|
67 } |
|
68 }, |
|
69 { |
|
70 setup: 'connect remote', |
|
71 check: { |
|
72 args: { |
|
73 prefix: { value: 'remote' }, |
|
74 url: { value: undefined } |
|
75 } |
|
76 }, |
|
77 exec: { |
|
78 error: false |
|
79 } |
|
80 }, |
|
81 { |
|
82 setup: 'disconnect remote', |
|
83 check: { |
|
84 args: { |
|
85 prefix: { |
|
86 value: function(connection) { |
|
87 assert.is(connection.prefix, 'remote', 'disconnecting remote'); |
|
88 } |
|
89 } |
|
90 } |
|
91 }, |
|
92 exec: { |
|
93 output: /^Removed [0-9]* commands.$/, |
|
94 type: 'string', |
|
95 error: false |
|
96 } |
|
97 }, |
|
98 { |
|
99 setup: 'connect remote --method xhr', |
|
100 check: { |
|
101 args: { |
|
102 prefix: { value: 'remote' }, |
|
103 url: { value: undefined } |
|
104 } |
|
105 }, |
|
106 exec: { |
|
107 error: false |
|
108 } |
|
109 }, |
|
110 { |
|
111 setup: 'disconnect remote', |
|
112 check: { |
|
113 args: { |
|
114 prefix: { |
|
115 value: function(connection) { |
|
116 assert.is(connection.prefix, 'remote', 'disconnecting remote'); |
|
117 } |
|
118 } |
|
119 } |
|
120 }, |
|
121 exec: { |
|
122 output: /^Removed [0-9]* commands.$/, |
|
123 type: 'string', |
|
124 error: false |
|
125 } |
|
126 }, |
|
127 { |
|
128 setup: 'connect remote --method xhr', |
|
129 check: { |
|
130 args: { |
|
131 prefix: { value: 'remote' }, |
|
132 url: { value: undefined } |
|
133 } |
|
134 }, |
|
135 exec: { |
|
136 output: /^Added [0-9]* commands.$/, |
|
137 type: 'string', |
|
138 error: false |
|
139 } |
|
140 }, |
|
141 { |
|
142 setup: 'remote ', |
|
143 check: { |
|
144 input: 'remote ', |
|
145 // PhantomJS fails on this. Unsure why |
|
146 // hints: ' {', |
|
147 markup: 'IIIIIIV', |
|
148 status: 'ERROR', |
|
149 optionsIncludes: [ |
|
150 'remote', 'remote cd', 'remote context', 'remote echo', |
|
151 'remote exec', 'remote exit', 'remote firefox', 'remote help', |
|
152 'remote intro', 'remote make' |
|
153 ], |
|
154 message: '', |
|
155 predictionsIncludes: [ 'remote' ], |
|
156 unassigned: [ ], |
|
157 } |
|
158 }, |
|
159 { |
|
160 setup: 'remote echo hello world', |
|
161 check: { |
|
162 input: 'remote echo hello world', |
|
163 hints: '', |
|
164 markup: 'VVVVVVVVVVVVVVVVVVVVVVV', |
|
165 cursor: 23, |
|
166 current: 'message', |
|
167 status: 'VALID', |
|
168 options: [ ], |
|
169 message: '', |
|
170 predictions: [ ], |
|
171 unassigned: [ ], |
|
172 args: { |
|
173 command: { name: 'remote echo' }, |
|
174 message: { |
|
175 value: 'hello world', |
|
176 arg: ' hello world', |
|
177 status: 'VALID', |
|
178 message: '' |
|
179 } |
|
180 } |
|
181 }, |
|
182 exec: { |
|
183 output: 'hello world', |
|
184 type: 'string', |
|
185 error: false |
|
186 } |
|
187 }, |
|
188 { |
|
189 setup: 'remote exec ls', |
|
190 check: { |
|
191 input: 'remote exec ls', |
|
192 hints: '', |
|
193 markup: 'VVVVVVVVVVVVVV', |
|
194 cursor: 14, |
|
195 current: 'command', |
|
196 status: 'VALID', |
|
197 options: [ ], |
|
198 message: '', |
|
199 predictions: [ ], |
|
200 unassigned: [ ], |
|
201 args: { |
|
202 command: { |
|
203 value: 'ls', |
|
204 arg: ' ls', |
|
205 status: 'VALID', |
|
206 message: '' |
|
207 } |
|
208 } |
|
209 }, |
|
210 exec: { |
|
211 // output: '', We can't rely on the contents of the FS |
|
212 type: 'output', |
|
213 error: false |
|
214 } |
|
215 }, |
|
216 { |
|
217 setup: 'remote sleep mistake', |
|
218 check: { |
|
219 input: 'remote sleep mistake', |
|
220 hints: '', |
|
221 markup: 'VVVVVVVVVVVVVEEEEEEE', |
|
222 cursor: 20, |
|
223 current: 'length', |
|
224 status: 'ERROR', |
|
225 options: [ ], |
|
226 message: 'Can\'t convert "mistake" to a number.', |
|
227 predictions: [ ], |
|
228 unassigned: [ ], |
|
229 args: { |
|
230 command: { name: 'remote sleep' }, |
|
231 length: { |
|
232 value: undefined, |
|
233 arg: ' mistake', |
|
234 status: 'ERROR', |
|
235 message: 'Can\'t convert "mistake" to a number.' |
|
236 } |
|
237 } |
|
238 } |
|
239 }, |
|
240 { |
|
241 setup: 'remote sleep 1', |
|
242 check: { |
|
243 input: 'remote sleep 1', |
|
244 hints: '', |
|
245 markup: 'VVVVVVVVVVVVVV', |
|
246 cursor: 14, |
|
247 current: 'length', |
|
248 status: 'VALID', |
|
249 options: [ ], |
|
250 message: '', |
|
251 predictions: [ ], |
|
252 unassigned: [ ], |
|
253 args: { |
|
254 command: { name: 'remote sleep' }, |
|
255 length: { value: 1, arg: ' 1', status: 'VALID', message: '' } |
|
256 } |
|
257 }, |
|
258 exec: { |
|
259 output: 'Done', |
|
260 type: 'string', |
|
261 error: false |
|
262 } |
|
263 }, |
|
264 { |
|
265 setup: 'remote help ', |
|
266 skipIf: true, // The help command is not remotable |
|
267 check: { |
|
268 input: 'remote help ', |
|
269 hints: '[search]', |
|
270 markup: 'VVVVVVVVVVVV', |
|
271 cursor: 12, |
|
272 current: 'search', |
|
273 status: 'VALID', |
|
274 options: [ ], |
|
275 message: '', |
|
276 predictions: [ ], |
|
277 unassigned: [ ], |
|
278 args: { |
|
279 command: { name: 'remote help' }, |
|
280 search: { |
|
281 value: undefined, |
|
282 arg: '', |
|
283 status: 'VALID', |
|
284 message: '' |
|
285 } |
|
286 } |
|
287 }, |
|
288 exec: { |
|
289 output: '', |
|
290 type: 'string', |
|
291 error: false |
|
292 } |
|
293 }, |
|
294 { |
|
295 setup: 'remote intro', |
|
296 check: { |
|
297 input: 'remote intro', |
|
298 hints: '', |
|
299 markup: 'VVVVVVVVVVVV', |
|
300 cursor: 12, |
|
301 current: '__command', |
|
302 status: 'VALID', |
|
303 options: [ ], |
|
304 message: '', |
|
305 predictions: [ ], |
|
306 unassigned: [ ], |
|
307 args: { |
|
308 command: { name: 'remote intro' } |
|
309 } |
|
310 }, |
|
311 exec: { |
|
312 output: [ |
|
313 /^GCLI is an experiment/, |
|
314 /F1\/Escape/ |
|
315 ], |
|
316 type: 'intro', |
|
317 error: false |
|
318 } |
|
319 }, |
|
320 { |
|
321 setup: 'context remote', |
|
322 check: { |
|
323 input: 'context remote', |
|
324 // hints: ' {', |
|
325 markup: 'VVVVVVVVVVVVVV', |
|
326 cursor: 14, |
|
327 current: 'prefix', |
|
328 status: 'VALID', |
|
329 optionsContains: [ |
|
330 'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit', |
|
331 'remote firefox', 'remote help', 'remote intro', 'remote make' |
|
332 ], |
|
333 message: '', |
|
334 // predictionsContains: [ |
|
335 // 'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit', |
|
336 // 'remote firefox', 'remote help', 'remote intro', 'remote make', |
|
337 // 'remote pref' |
|
338 // ], |
|
339 unassigned: [ ], |
|
340 args: { |
|
341 command: { name: 'context' }, |
|
342 prefix: { |
|
343 arg: ' remote', |
|
344 status: 'VALID', |
|
345 message: '' |
|
346 } |
|
347 } |
|
348 }, |
|
349 exec: { |
|
350 output: 'Using remote as a command prefix', |
|
351 type: 'string', |
|
352 error: false |
|
353 } |
|
354 }, |
|
355 { |
|
356 setup: 'exec ls', |
|
357 check: { |
|
358 input: 'exec ls', |
|
359 hints: '', |
|
360 markup: 'VVVVVVV', |
|
361 cursor: 7, |
|
362 current: 'command', |
|
363 status: 'VALID', |
|
364 options: [ ], |
|
365 message: '', |
|
366 predictions: [ ], |
|
367 unassigned: [ ], |
|
368 args: { |
|
369 command: { value: 'ls', arg: ' ls', status: 'VALID', message: '' }, |
|
370 } |
|
371 }, |
|
372 exec: { |
|
373 // output: '', We can't rely on the contents of the filesystem |
|
374 type: 'output', |
|
375 error: false |
|
376 } |
|
377 }, |
|
378 { |
|
379 setup: 'echo hello world', |
|
380 check: { |
|
381 input: 'echo hello world', |
|
382 hints: '', |
|
383 markup: 'VVVVVVVVVVVVVVVV', |
|
384 cursor: 16, |
|
385 current: 'message', |
|
386 status: 'VALID', |
|
387 options: [ ], |
|
388 message: '', |
|
389 predictions: [ ], |
|
390 unassigned: [ ], |
|
391 args: { |
|
392 command: { name: 'remote echo' }, |
|
393 message: { |
|
394 value: 'hello world', |
|
395 arg: ' hello world', |
|
396 status: 'VALID', |
|
397 message: '' |
|
398 } |
|
399 } |
|
400 }, |
|
401 exec: { |
|
402 output: /^hello world$/, |
|
403 type: 'string', |
|
404 error: false |
|
405 } |
|
406 }, |
|
407 { |
|
408 setup: 'context', |
|
409 check: { |
|
410 input: 'context', |
|
411 hints: ' [prefix]', |
|
412 markup: 'VVVVVVV', |
|
413 cursor: 7, |
|
414 current: '__command', |
|
415 status: 'VALID', |
|
416 optionsContains: [ |
|
417 'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit', |
|
418 'remote firefox', 'remote help', 'remote intro', 'remote make' |
|
419 ], |
|
420 message: '', |
|
421 predictions: [ ], |
|
422 unassigned: [ ], |
|
423 args: { |
|
424 command: { name: 'context' }, |
|
425 prefix: { value: undefined, arg: '', status: 'VALID', message: '' } |
|
426 } |
|
427 }, |
|
428 exec: { |
|
429 output: 'Command prefix is unset', |
|
430 type: 'string', |
|
431 error: false |
|
432 } |
|
433 }, |
|
434 { |
|
435 setup: 'disconnect ', |
|
436 check: { |
|
437 input: 'disconnect ', |
|
438 hints: 'remote', |
|
439 markup: 'VVVVVVVVVVV', |
|
440 cursor: 11, |
|
441 current: 'prefix', |
|
442 status: 'ERROR', |
|
443 options: [ 'remote' ], |
|
444 message: '', |
|
445 predictions: [ 'remote' ], |
|
446 unassigned: [ ], |
|
447 args: { |
|
448 command: { name: 'disconnect' }, |
|
449 prefix: { |
|
450 value: undefined, |
|
451 arg: '', |
|
452 status: 'INCOMPLETE', |
|
453 message: 'Value required for \'prefix\'.' |
|
454 } |
|
455 } |
|
456 } |
|
457 }, |
|
458 { |
|
459 setup: 'disconnect remote', |
|
460 check: { |
|
461 input: 'disconnect remote', |
|
462 hints: '', |
|
463 markup: 'VVVVVVVVVVVVVVVVV', |
|
464 status: 'VALID', |
|
465 message: '', |
|
466 unassigned: [ ], |
|
467 args: { |
|
468 prefix: { |
|
469 value: function(connection) { |
|
470 assert.is(connection.prefix, 'remote', 'disconnecting remote'); |
|
471 }, |
|
472 arg: ' remote', |
|
473 status: 'VALID', |
|
474 message: '' |
|
475 } |
|
476 } |
|
477 }, |
|
478 exec: { |
|
479 output: /^Removed [0-9]* commands.$/, |
|
480 type: 'string', |
|
481 error: false |
|
482 } |
|
483 }, |
|
484 { |
|
485 setup: 'remote ', |
|
486 check: { |
|
487 input: 'remote ', |
|
488 hints: '', |
|
489 markup: 'EEEEEEV', |
|
490 cursor: 7, |
|
491 current: '__command', |
|
492 status: 'ERROR', |
|
493 options: [ ], |
|
494 message: 'Can\'t use \'remote\'.', |
|
495 predictions: [ ], |
|
496 unassigned: [ ], |
|
497 } |
|
498 } |
|
499 ]); |
|
500 }; |