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.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012, Mozilla Foundation and contributors |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | 'use strict'; |
michael@0 | 18 | // <INJECTED SOURCE:START> |
michael@0 | 19 | |
michael@0 | 20 | // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT |
michael@0 | 21 | // DO NOT EDIT IT DIRECTLY |
michael@0 | 22 | |
michael@0 | 23 | // <INJECTED SOURCE:END> |
michael@0 | 24 | |
michael@0 | 25 | |
michael@0 | 26 | var mockCommands = {}; |
michael@0 | 27 | |
michael@0 | 28 | // We use an alias for exports here because this module is used in Firefox |
michael@0 | 29 | // mochitests where we don't have define/require |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * Registration and de-registration. |
michael@0 | 33 | */ |
michael@0 | 34 | mockCommands.setup = function(requisition) { |
michael@0 | 35 | mockCommands.items.forEach(function(item) { |
michael@0 | 36 | if (item.item === 'command') { |
michael@0 | 37 | requisition.canon.addCommand(item); |
michael@0 | 38 | } |
michael@0 | 39 | else if (item.item === 'type') { |
michael@0 | 40 | requisition.types.addType(item); |
michael@0 | 41 | } |
michael@0 | 42 | else { |
michael@0 | 43 | console.error('Ignoring item ', item); |
michael@0 | 44 | } |
michael@0 | 45 | }); |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | mockCommands.shutdown = function(requisition) { |
michael@0 | 49 | mockCommands.items.forEach(function(item) { |
michael@0 | 50 | if (item.item === 'command') { |
michael@0 | 51 | requisition.canon.removeCommand(item); |
michael@0 | 52 | } |
michael@0 | 53 | else if (item.item === 'type') { |
michael@0 | 54 | requisition.types.removeType(item); |
michael@0 | 55 | } |
michael@0 | 56 | else { |
michael@0 | 57 | console.error('Ignoring item ', item); |
michael@0 | 58 | } |
michael@0 | 59 | }); |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | function createExec(name) { |
michael@0 | 63 | return function(args, executionContext) { |
michael@0 | 64 | var argsOut = Object.keys(args).map(function(key) { |
michael@0 | 65 | return key + '=' + args[key]; |
michael@0 | 66 | }).join(', '); |
michael@0 | 67 | return 'Exec: ' + name + ' ' + argsOut; |
michael@0 | 68 | }; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | mockCommands.items = [ |
michael@0 | 72 | { |
michael@0 | 73 | item: 'type', |
michael@0 | 74 | name: 'optionType', |
michael@0 | 75 | parent: 'selection', |
michael@0 | 76 | lookup: [ |
michael@0 | 77 | { |
michael@0 | 78 | name: 'option1', |
michael@0 | 79 | value: 'string' |
michael@0 | 80 | }, |
michael@0 | 81 | { |
michael@0 | 82 | name: 'option2', |
michael@0 | 83 | value: 'number' |
michael@0 | 84 | }, |
michael@0 | 85 | { |
michael@0 | 86 | name: 'option3', |
michael@0 | 87 | value: { |
michael@0 | 88 | name: 'selection', |
michael@0 | 89 | lookup: [ |
michael@0 | 90 | { name: 'one', value: 1 }, |
michael@0 | 91 | { name: 'two', value: 2 }, |
michael@0 | 92 | { name: 'three', value: 3 } |
michael@0 | 93 | ] |
michael@0 | 94 | } |
michael@0 | 95 | } |
michael@0 | 96 | ] |
michael@0 | 97 | }, |
michael@0 | 98 | { |
michael@0 | 99 | item: 'type', |
michael@0 | 100 | name: 'optionValue', |
michael@0 | 101 | parent: 'delegate', |
michael@0 | 102 | delegateType: function(executionContext) { |
michael@0 | 103 | if (executionContext != null) { |
michael@0 | 104 | var option = executionContext.getArgsObject().optionType; |
michael@0 | 105 | if (option != null) { |
michael@0 | 106 | return option; |
michael@0 | 107 | } |
michael@0 | 108 | } |
michael@0 | 109 | return 'blank'; |
michael@0 | 110 | } |
michael@0 | 111 | }, |
michael@0 | 112 | { |
michael@0 | 113 | item: 'command', |
michael@0 | 114 | name: 'tsv', |
michael@0 | 115 | params: [ |
michael@0 | 116 | { name: 'optionType', type: 'optionType' }, |
michael@0 | 117 | { name: 'optionValue', type: 'optionValue' } |
michael@0 | 118 | ], |
michael@0 | 119 | exec: createExec('tsv') |
michael@0 | 120 | }, |
michael@0 | 121 | { |
michael@0 | 122 | item: 'command', |
michael@0 | 123 | name: 'tsr', |
michael@0 | 124 | params: [ { name: 'text', type: 'string' } ], |
michael@0 | 125 | exec: createExec('tsr') |
michael@0 | 126 | }, |
michael@0 | 127 | { |
michael@0 | 128 | item: 'command', |
michael@0 | 129 | name: 'tsrsrsr', |
michael@0 | 130 | params: [ |
michael@0 | 131 | { name: 'p1', type: 'string' }, |
michael@0 | 132 | { name: 'p2', type: 'string' }, |
michael@0 | 133 | { name: 'p3', type: { name: 'string', allowBlank: true} }, |
michael@0 | 134 | ], |
michael@0 | 135 | exec: createExec('tsrsrsr') |
michael@0 | 136 | }, |
michael@0 | 137 | { |
michael@0 | 138 | item: 'command', |
michael@0 | 139 | name: 'tso', |
michael@0 | 140 | params: [ { name: 'text', type: 'string', defaultValue: null } ], |
michael@0 | 141 | exec: createExec('tso') |
michael@0 | 142 | }, |
michael@0 | 143 | { |
michael@0 | 144 | item: 'command', |
michael@0 | 145 | name: 'tse', |
michael@0 | 146 | params: [ |
michael@0 | 147 | { name: 'node', type: 'node' }, |
michael@0 | 148 | { |
michael@0 | 149 | group: 'options', |
michael@0 | 150 | params: [ |
michael@0 | 151 | { name: 'nodes', type: { name: 'nodelist' } }, |
michael@0 | 152 | { name: 'nodes2', type: { name: 'nodelist', allowEmpty: true } } |
michael@0 | 153 | ] |
michael@0 | 154 | } |
michael@0 | 155 | ], |
michael@0 | 156 | exec: createExec('tse') |
michael@0 | 157 | }, |
michael@0 | 158 | { |
michael@0 | 159 | item: 'command', |
michael@0 | 160 | name: 'tsj', |
michael@0 | 161 | params: [ { name: 'javascript', type: 'javascript' } ], |
michael@0 | 162 | exec: createExec('tsj') |
michael@0 | 163 | }, |
michael@0 | 164 | { |
michael@0 | 165 | item: 'command', |
michael@0 | 166 | name: 'tsb', |
michael@0 | 167 | params: [ { name: 'toggle', type: 'boolean' } ], |
michael@0 | 168 | exec: createExec('tsb') |
michael@0 | 169 | }, |
michael@0 | 170 | { |
michael@0 | 171 | item: 'command', |
michael@0 | 172 | name: 'tss', |
michael@0 | 173 | exec: createExec('tss') |
michael@0 | 174 | }, |
michael@0 | 175 | { |
michael@0 | 176 | item: 'command', |
michael@0 | 177 | name: 'tsu', |
michael@0 | 178 | params: [ |
michael@0 | 179 | { |
michael@0 | 180 | name: 'num', |
michael@0 | 181 | type: { |
michael@0 | 182 | name: 'number', |
michael@0 | 183 | max: 10, |
michael@0 | 184 | min: -5, |
michael@0 | 185 | step: 3 |
michael@0 | 186 | } |
michael@0 | 187 | } |
michael@0 | 188 | ], |
michael@0 | 189 | exec: createExec('tsu') |
michael@0 | 190 | }, |
michael@0 | 191 | { |
michael@0 | 192 | item: 'command', |
michael@0 | 193 | name: 'tsf', |
michael@0 | 194 | params: [ |
michael@0 | 195 | { |
michael@0 | 196 | name: 'num', |
michael@0 | 197 | type: { |
michael@0 | 198 | name: 'number', |
michael@0 | 199 | allowFloat: true, |
michael@0 | 200 | max: 11.5, |
michael@0 | 201 | min: -6.5, |
michael@0 | 202 | step: 1.5 |
michael@0 | 203 | } |
michael@0 | 204 | } |
michael@0 | 205 | ], |
michael@0 | 206 | exec: createExec('tsf') |
michael@0 | 207 | }, |
michael@0 | 208 | { |
michael@0 | 209 | item: 'command', |
michael@0 | 210 | name: 'tsn' |
michael@0 | 211 | }, |
michael@0 | 212 | { |
michael@0 | 213 | item: 'command', |
michael@0 | 214 | name: 'tsn dif', |
michael@0 | 215 | params: [ { name: 'text', type: 'string', description: 'tsn dif text' } ], |
michael@0 | 216 | exec: createExec('tsnDif') |
michael@0 | 217 | }, |
michael@0 | 218 | { |
michael@0 | 219 | item: 'command', |
michael@0 | 220 | name: 'tsn hidden', |
michael@0 | 221 | hidden: true, |
michael@0 | 222 | exec: createExec('tsnHidden') |
michael@0 | 223 | }, |
michael@0 | 224 | { |
michael@0 | 225 | item: 'command', |
michael@0 | 226 | name: 'tsn ext', |
michael@0 | 227 | params: [ { name: 'text', type: 'string' } ], |
michael@0 | 228 | exec: createExec('tsnExt') |
michael@0 | 229 | }, |
michael@0 | 230 | { |
michael@0 | 231 | item: 'command', |
michael@0 | 232 | name: 'tsn exte', |
michael@0 | 233 | params: [ { name: 'text', type: 'string' } ], |
michael@0 | 234 | exec: createExec('tsnExte') |
michael@0 | 235 | }, |
michael@0 | 236 | { |
michael@0 | 237 | item: 'command', |
michael@0 | 238 | name: 'tsn exten', |
michael@0 | 239 | params: [ { name: 'text', type: 'string' } ], |
michael@0 | 240 | exec: createExec('tsnExten') |
michael@0 | 241 | }, |
michael@0 | 242 | { |
michael@0 | 243 | item: 'command', |
michael@0 | 244 | name: 'tsn extend', |
michael@0 | 245 | params: [ { name: 'text', type: 'string' } ], |
michael@0 | 246 | exec: createExec('tsnExtend') |
michael@0 | 247 | }, |
michael@0 | 248 | { |
michael@0 | 249 | item: 'command', |
michael@0 | 250 | name: 'tsn deep' |
michael@0 | 251 | }, |
michael@0 | 252 | { |
michael@0 | 253 | item: 'command', |
michael@0 | 254 | name: 'tsn deep down' |
michael@0 | 255 | }, |
michael@0 | 256 | { |
michael@0 | 257 | item: 'command', |
michael@0 | 258 | name: 'tsn deep down nested' |
michael@0 | 259 | }, |
michael@0 | 260 | { |
michael@0 | 261 | item: 'command', |
michael@0 | 262 | name: 'tsn deep down nested cmd', |
michael@0 | 263 | exec: createExec('tsnDeepDownNestedCmd') |
michael@0 | 264 | }, |
michael@0 | 265 | { |
michael@0 | 266 | item: 'command', |
michael@0 | 267 | name: 'tshidden', |
michael@0 | 268 | hidden: true, |
michael@0 | 269 | params: [ |
michael@0 | 270 | { |
michael@0 | 271 | group: 'Options', |
michael@0 | 272 | params: [ |
michael@0 | 273 | { |
michael@0 | 274 | name: 'visible', |
michael@0 | 275 | type: 'string', |
michael@0 | 276 | short: 'v', |
michael@0 | 277 | defaultValue: null, |
michael@0 | 278 | description: 'visible' |
michael@0 | 279 | }, |
michael@0 | 280 | { |
michael@0 | 281 | name: 'invisiblestring', |
michael@0 | 282 | type: 'string', |
michael@0 | 283 | short: 'i', |
michael@0 | 284 | description: 'invisiblestring', |
michael@0 | 285 | defaultValue: null, |
michael@0 | 286 | hidden: true |
michael@0 | 287 | }, |
michael@0 | 288 | { |
michael@0 | 289 | name: 'invisibleboolean', |
michael@0 | 290 | short: 'b', |
michael@0 | 291 | type: 'boolean', |
michael@0 | 292 | description: 'invisibleboolean', |
michael@0 | 293 | hidden: true |
michael@0 | 294 | } |
michael@0 | 295 | ] |
michael@0 | 296 | } |
michael@0 | 297 | ], |
michael@0 | 298 | exec: createExec('tshidden') |
michael@0 | 299 | }, |
michael@0 | 300 | { |
michael@0 | 301 | item: 'command', |
michael@0 | 302 | name: 'tselarr', |
michael@0 | 303 | params: [ |
michael@0 | 304 | { name: 'num', type: { name: 'selection', data: [ '1', '2', '3' ] } }, |
michael@0 | 305 | { name: 'arr', type: { name: 'array', subtype: 'string' } } |
michael@0 | 306 | ], |
michael@0 | 307 | exec: createExec('tselarr') |
michael@0 | 308 | }, |
michael@0 | 309 | { |
michael@0 | 310 | item: 'command', |
michael@0 | 311 | name: 'tsm', |
michael@0 | 312 | description: 'a 3-param test selection|string|number', |
michael@0 | 313 | params: [ |
michael@0 | 314 | { name: 'abc', type: { name: 'selection', data: [ 'a', 'b', 'c' ] } }, |
michael@0 | 315 | { name: 'txt', type: 'string' }, |
michael@0 | 316 | { name: 'num', type: { name: 'number', max: 42, min: 0 } } |
michael@0 | 317 | ], |
michael@0 | 318 | exec: createExec('tsm') |
michael@0 | 319 | }, |
michael@0 | 320 | { |
michael@0 | 321 | item: 'command', |
michael@0 | 322 | name: 'tsg', |
michael@0 | 323 | description: 'a param group test', |
michael@0 | 324 | params: [ |
michael@0 | 325 | { |
michael@0 | 326 | name: 'solo', |
michael@0 | 327 | type: { name: 'selection', data: [ 'aaa', 'bbb', 'ccc' ] }, |
michael@0 | 328 | description: 'solo param' |
michael@0 | 329 | }, |
michael@0 | 330 | { |
michael@0 | 331 | group: 'First', |
michael@0 | 332 | params: [ |
michael@0 | 333 | { |
michael@0 | 334 | name: 'txt1', |
michael@0 | 335 | type: 'string', |
michael@0 | 336 | defaultValue: null, |
michael@0 | 337 | description: 'txt1 param' |
michael@0 | 338 | }, |
michael@0 | 339 | { |
michael@0 | 340 | name: 'bool', |
michael@0 | 341 | type: 'boolean', |
michael@0 | 342 | description: 'bool param' |
michael@0 | 343 | } |
michael@0 | 344 | ] |
michael@0 | 345 | }, |
michael@0 | 346 | { |
michael@0 | 347 | name: 'txt2', |
michael@0 | 348 | type: 'string', |
michael@0 | 349 | defaultValue: 'd', |
michael@0 | 350 | description: 'txt2 param', |
michael@0 | 351 | option: 'Second' |
michael@0 | 352 | }, |
michael@0 | 353 | { |
michael@0 | 354 | name: 'num', |
michael@0 | 355 | type: { name: 'number', min: 40 }, |
michael@0 | 356 | defaultValue: 42, |
michael@0 | 357 | description: 'num param', |
michael@0 | 358 | option: 'Second' |
michael@0 | 359 | } |
michael@0 | 360 | ], |
michael@0 | 361 | exec: createExec('tsg') |
michael@0 | 362 | }, |
michael@0 | 363 | { |
michael@0 | 364 | item: 'command', |
michael@0 | 365 | name: 'tscook', |
michael@0 | 366 | description: 'param group test to catch problems with cookie command', |
michael@0 | 367 | params: [ |
michael@0 | 368 | { |
michael@0 | 369 | name: 'key', |
michael@0 | 370 | type: 'string', |
michael@0 | 371 | description: 'tscookKeyDesc' |
michael@0 | 372 | }, |
michael@0 | 373 | { |
michael@0 | 374 | name: 'value', |
michael@0 | 375 | type: 'string', |
michael@0 | 376 | description: 'tscookValueDesc' |
michael@0 | 377 | }, |
michael@0 | 378 | { |
michael@0 | 379 | group: 'tscookOptionsDesc', |
michael@0 | 380 | params: [ |
michael@0 | 381 | { |
michael@0 | 382 | name: 'path', |
michael@0 | 383 | type: 'string', |
michael@0 | 384 | defaultValue: '/', |
michael@0 | 385 | description: 'tscookPathDesc' |
michael@0 | 386 | }, |
michael@0 | 387 | { |
michael@0 | 388 | name: 'domain', |
michael@0 | 389 | type: 'string', |
michael@0 | 390 | defaultValue: null, |
michael@0 | 391 | description: 'tscookDomainDesc' |
michael@0 | 392 | }, |
michael@0 | 393 | { |
michael@0 | 394 | name: 'secure', |
michael@0 | 395 | type: 'boolean', |
michael@0 | 396 | description: 'tscookSecureDesc' |
michael@0 | 397 | } |
michael@0 | 398 | ] |
michael@0 | 399 | } |
michael@0 | 400 | ], |
michael@0 | 401 | exec: createExec('tscook') |
michael@0 | 402 | }, |
michael@0 | 403 | { |
michael@0 | 404 | item: 'command', |
michael@0 | 405 | name: 'tslong', |
michael@0 | 406 | description: 'long param tests to catch problems with the jsb command', |
michael@0 | 407 | params: [ |
michael@0 | 408 | { |
michael@0 | 409 | name: 'msg', |
michael@0 | 410 | type: 'string', |
michael@0 | 411 | description: 'msg Desc' |
michael@0 | 412 | }, |
michael@0 | 413 | { |
michael@0 | 414 | group: 'Options Desc', |
michael@0 | 415 | params: [ |
michael@0 | 416 | { |
michael@0 | 417 | name: 'num', |
michael@0 | 418 | short: 'n', |
michael@0 | 419 | type: 'number', |
michael@0 | 420 | description: 'num Desc', |
michael@0 | 421 | defaultValue: 2 |
michael@0 | 422 | }, |
michael@0 | 423 | { |
michael@0 | 424 | name: 'sel', |
michael@0 | 425 | short: 's', |
michael@0 | 426 | type: { |
michael@0 | 427 | name: 'selection', |
michael@0 | 428 | lookup: [ |
michael@0 | 429 | { name: 'space', value: ' ' }, |
michael@0 | 430 | { name: 'tab', value: '\t' } |
michael@0 | 431 | ] |
michael@0 | 432 | }, |
michael@0 | 433 | description: 'sel Desc', |
michael@0 | 434 | defaultValue: ' ' |
michael@0 | 435 | }, |
michael@0 | 436 | { |
michael@0 | 437 | name: 'bool', |
michael@0 | 438 | short: 'b', |
michael@0 | 439 | type: 'boolean', |
michael@0 | 440 | description: 'bool Desc' |
michael@0 | 441 | }, |
michael@0 | 442 | { |
michael@0 | 443 | name: 'num2', |
michael@0 | 444 | short: 'm', |
michael@0 | 445 | type: 'number', |
michael@0 | 446 | description: 'num2 Desc', |
michael@0 | 447 | defaultValue: -1 |
michael@0 | 448 | }, |
michael@0 | 449 | { |
michael@0 | 450 | name: 'bool2', |
michael@0 | 451 | short: 'c', |
michael@0 | 452 | type: 'boolean', |
michael@0 | 453 | description: 'bool2 Desc' |
michael@0 | 454 | }, |
michael@0 | 455 | { |
michael@0 | 456 | name: 'sel2', |
michael@0 | 457 | short: 't', |
michael@0 | 458 | type: { |
michael@0 | 459 | name: 'selection', |
michael@0 | 460 | data: [ 'collapse', 'basic', 'with space', 'with two spaces' ] |
michael@0 | 461 | }, |
michael@0 | 462 | description: 'sel2 Desc', |
michael@0 | 463 | defaultValue: 'collapse' |
michael@0 | 464 | } |
michael@0 | 465 | ] |
michael@0 | 466 | } |
michael@0 | 467 | ], |
michael@0 | 468 | exec: createExec('tslong') |
michael@0 | 469 | }, |
michael@0 | 470 | { |
michael@0 | 471 | item: 'command', |
michael@0 | 472 | name: 'tsdate', |
michael@0 | 473 | description: 'long param tests to catch problems with the jsb command', |
michael@0 | 474 | params: [ |
michael@0 | 475 | { |
michael@0 | 476 | name: 'd1', |
michael@0 | 477 | type: 'date', |
michael@0 | 478 | }, |
michael@0 | 479 | { |
michael@0 | 480 | name: 'd2', |
michael@0 | 481 | type: { |
michael@0 | 482 | name: 'date', |
michael@0 | 483 | min: '1 jan 2000', |
michael@0 | 484 | max: '28 feb 2000', |
michael@0 | 485 | step: 2 |
michael@0 | 486 | } |
michael@0 | 487 | }, |
michael@0 | 488 | ], |
michael@0 | 489 | exec: createExec('tsdate') |
michael@0 | 490 | }, |
michael@0 | 491 | { |
michael@0 | 492 | item: 'command', |
michael@0 | 493 | name: 'tsfail', |
michael@0 | 494 | description: 'test errors', |
michael@0 | 495 | params: [ |
michael@0 | 496 | { |
michael@0 | 497 | name: 'method', |
michael@0 | 498 | type: { |
michael@0 | 499 | name: 'selection', |
michael@0 | 500 | data: [ |
michael@0 | 501 | 'reject', 'rejecttyped', |
michael@0 | 502 | 'throwerror', 'throwstring', 'throwinpromise', |
michael@0 | 503 | 'noerror' |
michael@0 | 504 | ] |
michael@0 | 505 | } |
michael@0 | 506 | } |
michael@0 | 507 | ], |
michael@0 | 508 | exec: function(args, context) { |
michael@0 | 509 | var deferred; |
michael@0 | 510 | if (args.method === 'reject') { |
michael@0 | 511 | deferred = context.defer(); |
michael@0 | 512 | setTimeout(function() { |
michael@0 | 513 | deferred.reject('rejected promise'); |
michael@0 | 514 | }, 10); |
michael@0 | 515 | return deferred.promise; |
michael@0 | 516 | } |
michael@0 | 517 | |
michael@0 | 518 | if (args.method === 'rejecttyped') { |
michael@0 | 519 | deferred = context.defer(); |
michael@0 | 520 | setTimeout(function() { |
michael@0 | 521 | deferred.reject(context.typedData('number', 54)); |
michael@0 | 522 | }, 10); |
michael@0 | 523 | return deferred.promise; |
michael@0 | 524 | } |
michael@0 | 525 | |
michael@0 | 526 | if (args.method === 'throwinpromise') { |
michael@0 | 527 | deferred = context.defer(); |
michael@0 | 528 | setTimeout(function() { |
michael@0 | 529 | deferred.resolve('should be lost'); |
michael@0 | 530 | }, 10); |
michael@0 | 531 | return deferred.promise.then(function() { |
michael@0 | 532 | var t = null; |
michael@0 | 533 | return t.foo; |
michael@0 | 534 | }); |
michael@0 | 535 | } |
michael@0 | 536 | |
michael@0 | 537 | if (args.method === 'throwerror') { |
michael@0 | 538 | throw new Error('thrown error'); |
michael@0 | 539 | } |
michael@0 | 540 | |
michael@0 | 541 | if (args.method === 'throwstring') { |
michael@0 | 542 | throw 'thrown string'; |
michael@0 | 543 | } |
michael@0 | 544 | |
michael@0 | 545 | return 'no error'; |
michael@0 | 546 | } |
michael@0 | 547 | }, |
michael@0 | 548 | { |
michael@0 | 549 | item: 'command', |
michael@0 | 550 | name: 'tsfile', |
michael@0 | 551 | description: 'test file params', |
michael@0 | 552 | }, |
michael@0 | 553 | { |
michael@0 | 554 | item: 'command', |
michael@0 | 555 | name: 'tsfile open', |
michael@0 | 556 | description: 'a file param in open mode', |
michael@0 | 557 | params: [ |
michael@0 | 558 | { |
michael@0 | 559 | name: 'p1', |
michael@0 | 560 | type: { |
michael@0 | 561 | name: 'file', |
michael@0 | 562 | filetype: 'file', |
michael@0 | 563 | existing: 'yes' |
michael@0 | 564 | } |
michael@0 | 565 | } |
michael@0 | 566 | ], |
michael@0 | 567 | exec: createExec('tsfile open') |
michael@0 | 568 | }, |
michael@0 | 569 | { |
michael@0 | 570 | item: 'command', |
michael@0 | 571 | name: 'tsfile saveas', |
michael@0 | 572 | description: 'a file param in saveas mode', |
michael@0 | 573 | params: [ |
michael@0 | 574 | { |
michael@0 | 575 | name: 'p1', |
michael@0 | 576 | type: { |
michael@0 | 577 | name: 'file', |
michael@0 | 578 | filetype: 'file', |
michael@0 | 579 | existing: 'no' |
michael@0 | 580 | } |
michael@0 | 581 | } |
michael@0 | 582 | ], |
michael@0 | 583 | exec: createExec('tsfile saveas') |
michael@0 | 584 | }, |
michael@0 | 585 | { |
michael@0 | 586 | item: 'command', |
michael@0 | 587 | name: 'tsfile save', |
michael@0 | 588 | description: 'a file param in save mode', |
michael@0 | 589 | params: [ |
michael@0 | 590 | { |
michael@0 | 591 | name: 'p1', |
michael@0 | 592 | type: { |
michael@0 | 593 | name: 'file', |
michael@0 | 594 | filetype: 'file', |
michael@0 | 595 | existing: 'maybe' |
michael@0 | 596 | } |
michael@0 | 597 | } |
michael@0 | 598 | ], |
michael@0 | 599 | exec: createExec('tsfile save') |
michael@0 | 600 | }, |
michael@0 | 601 | { |
michael@0 | 602 | item: 'command', |
michael@0 | 603 | name: 'tsfile cd', |
michael@0 | 604 | description: 'a file param in cd mode', |
michael@0 | 605 | params: [ |
michael@0 | 606 | { |
michael@0 | 607 | name: 'p1', |
michael@0 | 608 | type: { |
michael@0 | 609 | name: 'file', |
michael@0 | 610 | filetype: 'directory', |
michael@0 | 611 | existing: 'yes' |
michael@0 | 612 | } |
michael@0 | 613 | } |
michael@0 | 614 | ], |
michael@0 | 615 | exec: createExec('tsfile cd') |
michael@0 | 616 | }, |
michael@0 | 617 | { |
michael@0 | 618 | item: 'command', |
michael@0 | 619 | name: 'tsfile mkdir', |
michael@0 | 620 | description: 'a file param in mkdir mode', |
michael@0 | 621 | params: [ |
michael@0 | 622 | { |
michael@0 | 623 | name: 'p1', |
michael@0 | 624 | type: { |
michael@0 | 625 | name: 'file', |
michael@0 | 626 | filetype: 'directory', |
michael@0 | 627 | existing: 'no' |
michael@0 | 628 | } |
michael@0 | 629 | } |
michael@0 | 630 | ], |
michael@0 | 631 | exec: createExec('tsfile mkdir') |
michael@0 | 632 | }, |
michael@0 | 633 | { |
michael@0 | 634 | item: 'command', |
michael@0 | 635 | name: 'tsfile rm', |
michael@0 | 636 | description: 'a file param in rm mode', |
michael@0 | 637 | params: [ |
michael@0 | 638 | { |
michael@0 | 639 | name: 'p1', |
michael@0 | 640 | type: { |
michael@0 | 641 | name: 'file', |
michael@0 | 642 | filetype: 'any', |
michael@0 | 643 | existing: 'yes' |
michael@0 | 644 | } |
michael@0 | 645 | } |
michael@0 | 646 | ], |
michael@0 | 647 | exec: createExec('tsfile rm') |
michael@0 | 648 | }, |
michael@0 | 649 | { |
michael@0 | 650 | item: 'command', |
michael@0 | 651 | name: 'tsslow', |
michael@0 | 652 | params: [ |
michael@0 | 653 | { |
michael@0 | 654 | name: 'hello', |
michael@0 | 655 | type: { |
michael@0 | 656 | name: 'selection', |
michael@0 | 657 | data: function(context) { |
michael@0 | 658 | var deferred = context.defer(); |
michael@0 | 659 | |
michael@0 | 660 | var resolve = function() { |
michael@0 | 661 | deferred.resolve([ |
michael@0 | 662 | 'Shalom', 'Namasté', 'Hallo', 'Dydd-da', |
michael@0 | 663 | 'Chào', 'Hej', 'Saluton', 'Sawubona' |
michael@0 | 664 | ]); |
michael@0 | 665 | }; |
michael@0 | 666 | |
michael@0 | 667 | setTimeout(resolve, 10); |
michael@0 | 668 | return deferred.promise; |
michael@0 | 669 | } |
michael@0 | 670 | } |
michael@0 | 671 | } |
michael@0 | 672 | ], |
michael@0 | 673 | exec: function(args, context) { |
michael@0 | 674 | return 'Test completed'; |
michael@0 | 675 | } |
michael@0 | 676 | } |
michael@0 | 677 | ]; |