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 | var exports = {}; |
michael@0 | 24 | |
michael@0 | 25 | var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testIncomplete.js</p>"; |
michael@0 | 26 | |
michael@0 | 27 | function test() { |
michael@0 | 28 | return Task.spawn(function() { |
michael@0 | 29 | let options = yield helpers.openTab(TEST_URI); |
michael@0 | 30 | yield helpers.openToolbar(options); |
michael@0 | 31 | gcli.addItems(mockCommands.items); |
michael@0 | 32 | |
michael@0 | 33 | yield helpers.runTests(options, exports); |
michael@0 | 34 | |
michael@0 | 35 | gcli.removeItems(mockCommands.items); |
michael@0 | 36 | yield helpers.closeToolbar(options); |
michael@0 | 37 | yield helpers.closeTab(options); |
michael@0 | 38 | }).then(finish, helpers.handleError); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | // <INJECTED SOURCE:END> |
michael@0 | 42 | |
michael@0 | 43 | // var assert = require('../testharness/assert'); |
michael@0 | 44 | // var helpers = require('./helpers'); |
michael@0 | 45 | |
michael@0 | 46 | exports.testBasic = function(options) { |
michael@0 | 47 | return helpers.audit(options, [ |
michael@0 | 48 | { |
michael@0 | 49 | setup: 'tsu 2 extra', |
michael@0 | 50 | check: { |
michael@0 | 51 | args: { |
michael@0 | 52 | num: { value: 2, type: 'Argument' } |
michael@0 | 53 | } |
michael@0 | 54 | }, |
michael@0 | 55 | post: function() { |
michael@0 | 56 | var requisition = options.requisition; |
michael@0 | 57 | |
michael@0 | 58 | assert.is(requisition._unassigned.length, |
michael@0 | 59 | 1, |
michael@0 | 60 | 'single unassigned: tsu 2 extra'); |
michael@0 | 61 | assert.is(requisition._unassigned[0].param.type.isIncompleteName, |
michael@0 | 62 | false, |
michael@0 | 63 | 'unassigned.isIncompleteName: tsu 2 extra'); |
michael@0 | 64 | } |
michael@0 | 65 | }, |
michael@0 | 66 | { |
michael@0 | 67 | setup: 'tsu', |
michael@0 | 68 | check: { |
michael@0 | 69 | args: { |
michael@0 | 70 | num: { value: undefined, type: 'BlankArgument' } |
michael@0 | 71 | } |
michael@0 | 72 | } |
michael@0 | 73 | }, |
michael@0 | 74 | { |
michael@0 | 75 | setup: 'tsg', |
michael@0 | 76 | check: { |
michael@0 | 77 | args: { |
michael@0 | 78 | solo: { type: 'BlankArgument' }, |
michael@0 | 79 | txt1: { type: 'BlankArgument' }, |
michael@0 | 80 | bool: { type: 'BlankArgument' }, |
michael@0 | 81 | txt2: { type: 'BlankArgument' }, |
michael@0 | 82 | num: { type: 'BlankArgument' } |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | ]); |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | exports.testCompleted = function(options) { |
michael@0 | 90 | return helpers.audit(options, [ |
michael@0 | 91 | { |
michael@0 | 92 | setup: 'tsela<TAB>', |
michael@0 | 93 | check: { |
michael@0 | 94 | args: { |
michael@0 | 95 | command: { name: 'tselarr', type: 'Argument' }, |
michael@0 | 96 | num: { type: 'BlankArgument' }, |
michael@0 | 97 | arr: { type: 'ArrayArgument' } |
michael@0 | 98 | } |
michael@0 | 99 | } |
michael@0 | 100 | }, |
michael@0 | 101 | { |
michael@0 | 102 | setup: 'tsn dif ', |
michael@0 | 103 | check: { |
michael@0 | 104 | input: 'tsn dif ', |
michael@0 | 105 | hints: '<text>', |
michael@0 | 106 | markup: 'VVVVVVVV', |
michael@0 | 107 | cursor: 8, |
michael@0 | 108 | status: 'ERROR', |
michael@0 | 109 | args: { |
michael@0 | 110 | command: { name: 'tsn dif', type: 'MergedArgument' }, |
michael@0 | 111 | text: { type: 'BlankArgument', status: 'INCOMPLETE' } |
michael@0 | 112 | } |
michael@0 | 113 | } |
michael@0 | 114 | }, |
michael@0 | 115 | { |
michael@0 | 116 | setup: 'tsn di<TAB>', |
michael@0 | 117 | check: { |
michael@0 | 118 | input: 'tsn dif ', |
michael@0 | 119 | hints: '<text>', |
michael@0 | 120 | markup: 'VVVVVVVV', |
michael@0 | 121 | cursor: 8, |
michael@0 | 122 | status: 'ERROR', |
michael@0 | 123 | args: { |
michael@0 | 124 | command: { name: 'tsn dif', type: 'Argument' }, |
michael@0 | 125 | text: { type: 'BlankArgument', status: 'INCOMPLETE' } |
michael@0 | 126 | } |
michael@0 | 127 | } |
michael@0 | 128 | }, |
michael@0 | 129 | // The above 2 tests take different routes to 'tsn dif '. |
michael@0 | 130 | // The results should be similar. The difference is in args.command.type. |
michael@0 | 131 | { |
michael@0 | 132 | setup: 'tsg -', |
michael@0 | 133 | check: { |
michael@0 | 134 | input: 'tsg -', |
michael@0 | 135 | hints: '-txt1 <solo> [options]', |
michael@0 | 136 | markup: 'VVVVI', |
michael@0 | 137 | cursor: 5, |
michael@0 | 138 | status: 'ERROR', |
michael@0 | 139 | args: { |
michael@0 | 140 | solo: { value: undefined, status: 'INCOMPLETE' }, |
michael@0 | 141 | txt1: { value: undefined, status: 'VALID' }, |
michael@0 | 142 | bool: { value: false, status: 'VALID' }, |
michael@0 | 143 | txt2: { value: undefined, status: 'VALID' }, |
michael@0 | 144 | num: { value: undefined, status: 'VALID' } |
michael@0 | 145 | } |
michael@0 | 146 | } |
michael@0 | 147 | }, |
michael@0 | 148 | { |
michael@0 | 149 | setup: 'tsg -<TAB>', |
michael@0 | 150 | check: { |
michael@0 | 151 | input: 'tsg --txt1 ', |
michael@0 | 152 | hints: '<string> <solo> [options]', |
michael@0 | 153 | markup: 'VVVVIIIIIIV', |
michael@0 | 154 | cursor: 11, |
michael@0 | 155 | status: 'ERROR', |
michael@0 | 156 | args: { |
michael@0 | 157 | solo: { value: undefined, status: 'INCOMPLETE' }, |
michael@0 | 158 | txt1: { value: undefined, status: 'INCOMPLETE' }, |
michael@0 | 159 | bool: { value: false, status: 'VALID' }, |
michael@0 | 160 | txt2: { value: undefined, status: 'VALID' }, |
michael@0 | 161 | num: { value: undefined, status: 'VALID' } |
michael@0 | 162 | } |
michael@0 | 163 | } |
michael@0 | 164 | }, |
michael@0 | 165 | { |
michael@0 | 166 | setup: 'tsg --txt1 fred', |
michael@0 | 167 | check: { |
michael@0 | 168 | input: 'tsg --txt1 fred', |
michael@0 | 169 | hints: ' <solo> [options]', |
michael@0 | 170 | markup: 'VVVVVVVVVVVVVVV', |
michael@0 | 171 | status: 'ERROR', |
michael@0 | 172 | args: { |
michael@0 | 173 | solo: { value: undefined, status: 'INCOMPLETE' }, |
michael@0 | 174 | txt1: { value: 'fred', status: 'VALID' }, |
michael@0 | 175 | bool: { value: false, status: 'VALID' }, |
michael@0 | 176 | txt2: { value: undefined, status: 'VALID' }, |
michael@0 | 177 | num: { value: undefined, status: 'VALID' } |
michael@0 | 178 | } |
michael@0 | 179 | } |
michael@0 | 180 | }, |
michael@0 | 181 | { |
michael@0 | 182 | setup: 'tscook key value --path path --', |
michael@0 | 183 | check: { |
michael@0 | 184 | input: 'tscook key value --path path --', |
michael@0 | 185 | hints: 'domain [options]', |
michael@0 | 186 | markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVII', |
michael@0 | 187 | status: 'ERROR', |
michael@0 | 188 | args: { |
michael@0 | 189 | key: { value: 'key', status: 'VALID' }, |
michael@0 | 190 | value: { value: 'value', status: 'VALID' }, |
michael@0 | 191 | path: { value: 'path', status: 'VALID' }, |
michael@0 | 192 | domain: { value: undefined, status: 'VALID' }, |
michael@0 | 193 | secure: { value: false, status: 'VALID' } |
michael@0 | 194 | } |
michael@0 | 195 | } |
michael@0 | 196 | }, |
michael@0 | 197 | { |
michael@0 | 198 | setup: 'tscook key value --path path --domain domain --', |
michael@0 | 199 | check: { |
michael@0 | 200 | input: 'tscook key value --path path --domain domain --', |
michael@0 | 201 | hints: 'secure [options]', |
michael@0 | 202 | markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVII', |
michael@0 | 203 | status: 'ERROR', |
michael@0 | 204 | args: { |
michael@0 | 205 | key: { value: 'key', status: 'VALID' }, |
michael@0 | 206 | value: { value: 'value', status: 'VALID' }, |
michael@0 | 207 | path: { value: 'path', status: 'VALID' }, |
michael@0 | 208 | domain: { value: 'domain', status: 'VALID' }, |
michael@0 | 209 | secure: { value: false, status: 'VALID' } |
michael@0 | 210 | } |
michael@0 | 211 | } |
michael@0 | 212 | } |
michael@0 | 213 | ]); |
michael@0 | 214 | |
michael@0 | 215 | }; |
michael@0 | 216 | |
michael@0 | 217 | exports.testCase = function(options) { |
michael@0 | 218 | return helpers.audit(options, [ |
michael@0 | 219 | { |
michael@0 | 220 | setup: 'tsg AA', |
michael@0 | 221 | check: { |
michael@0 | 222 | input: 'tsg AA', |
michael@0 | 223 | hints: ' [options] -> aaa', |
michael@0 | 224 | markup: 'VVVVII', |
michael@0 | 225 | status: 'ERROR', |
michael@0 | 226 | args: { |
michael@0 | 227 | solo: { value: undefined, text: 'AA', status: 'INCOMPLETE' }, |
michael@0 | 228 | txt1: { value: undefined, status: 'VALID' }, |
michael@0 | 229 | bool: { value: false, status: 'VALID' }, |
michael@0 | 230 | txt2: { value: undefined, status: 'VALID' }, |
michael@0 | 231 | num: { value: undefined, status: 'VALID' } |
michael@0 | 232 | } |
michael@0 | 233 | } |
michael@0 | 234 | } |
michael@0 | 235 | ]); |
michael@0 | 236 | }; |
michael@0 | 237 | |
michael@0 | 238 | exports.testIncomplete = function(options) { |
michael@0 | 239 | return helpers.audit(options, [ |
michael@0 | 240 | { |
michael@0 | 241 | setup: 'tsm a a -', |
michael@0 | 242 | check: { |
michael@0 | 243 | args: { |
michael@0 | 244 | abc: { value: 'a', type: 'Argument' }, |
michael@0 | 245 | txt: { value: 'a', type: 'Argument' }, |
michael@0 | 246 | num: { value: undefined, arg: ' -', type: 'Argument', status: 'INCOMPLETE' } |
michael@0 | 247 | } |
michael@0 | 248 | } |
michael@0 | 249 | }, |
michael@0 | 250 | { |
michael@0 | 251 | setup: 'tsg -', |
michael@0 | 252 | check: { |
michael@0 | 253 | args: { |
michael@0 | 254 | solo: { type: 'BlankArgument' }, |
michael@0 | 255 | txt1: { type: 'BlankArgument' }, |
michael@0 | 256 | bool: { type: 'BlankArgument' }, |
michael@0 | 257 | txt2: { type: 'BlankArgument' }, |
michael@0 | 258 | num: { type: 'BlankArgument' } |
michael@0 | 259 | } |
michael@0 | 260 | }, |
michael@0 | 261 | post: function() { |
michael@0 | 262 | var requisition = options.requisition; |
michael@0 | 263 | |
michael@0 | 264 | assert.is(requisition._unassigned[0], |
michael@0 | 265 | requisition.getAssignmentAt(5), |
michael@0 | 266 | 'unassigned -'); |
michael@0 | 267 | assert.is(requisition._unassigned.length, |
michael@0 | 268 | 1, |
michael@0 | 269 | 'single unassigned - tsg -'); |
michael@0 | 270 | assert.is(requisition._unassigned[0].param.type.isIncompleteName, |
michael@0 | 271 | true, |
michael@0 | 272 | 'unassigned.isIncompleteName: tsg -'); |
michael@0 | 273 | } |
michael@0 | 274 | } |
michael@0 | 275 | ]); |
michael@0 | 276 | }; |
michael@0 | 277 | |
michael@0 | 278 | exports.testRepeated = function(options) { |
michael@0 | 279 | return helpers.audit(options, [ |
michael@0 | 280 | { |
michael@0 | 281 | setup: 'tscook key value --path jjj --path kkk', |
michael@0 | 282 | check: { |
michael@0 | 283 | input: 'tscook key value --path jjj --path kkk', |
michael@0 | 284 | hints: ' [options]', |
michael@0 | 285 | markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVEEEEEEVEEE', |
michael@0 | 286 | cursor: 38, |
michael@0 | 287 | current: '__unassigned', |
michael@0 | 288 | status: 'ERROR', |
michael@0 | 289 | options: [ ], |
michael@0 | 290 | message: '', |
michael@0 | 291 | predictions: [ ], |
michael@0 | 292 | unassigned: [ ' --path', ' kkk' ], |
michael@0 | 293 | args: { |
michael@0 | 294 | command: { name: 'tscook' }, |
michael@0 | 295 | key: { |
michael@0 | 296 | value: 'key', |
michael@0 | 297 | arg: ' key', |
michael@0 | 298 | status: 'VALID', |
michael@0 | 299 | message: '' |
michael@0 | 300 | }, |
michael@0 | 301 | value: { |
michael@0 | 302 | value: 'value', |
michael@0 | 303 | arg: ' value', |
michael@0 | 304 | status: 'VALID', |
michael@0 | 305 | message: '' |
michael@0 | 306 | }, |
michael@0 | 307 | path: { |
michael@0 | 308 | value: 'jjj', |
michael@0 | 309 | arg: ' --path jjj', |
michael@0 | 310 | status: 'VALID', |
michael@0 | 311 | message: '' |
michael@0 | 312 | }, |
michael@0 | 313 | domain: { |
michael@0 | 314 | value: undefined, |
michael@0 | 315 | arg: '', |
michael@0 | 316 | status: 'VALID', |
michael@0 | 317 | message: '' |
michael@0 | 318 | }, |
michael@0 | 319 | secure: { |
michael@0 | 320 | value: false, |
michael@0 | 321 | arg: '', |
michael@0 | 322 | status: 'VALID', |
michael@0 | 323 | message: '' |
michael@0 | 324 | }, |
michael@0 | 325 | } |
michael@0 | 326 | } |
michael@0 | 327 | } |
michael@0 | 328 | ]); |
michael@0 | 329 | }; |
michael@0 | 330 | |
michael@0 | 331 | exports.testHidden = function(options) { |
michael@0 | 332 | return helpers.audit(options, [ |
michael@0 | 333 | { |
michael@0 | 334 | setup: 'tshidde', |
michael@0 | 335 | check: { |
michael@0 | 336 | input: 'tshidde', |
michael@0 | 337 | hints: ' -> tse', |
michael@0 | 338 | status: 'ERROR' |
michael@0 | 339 | } |
michael@0 | 340 | }, |
michael@0 | 341 | { |
michael@0 | 342 | setup: 'tshidden', |
michael@0 | 343 | check: { |
michael@0 | 344 | input: 'tshidden', |
michael@0 | 345 | hints: ' [options]', |
michael@0 | 346 | markup: 'VVVVVVVV', |
michael@0 | 347 | status: 'VALID', |
michael@0 | 348 | args: { |
michael@0 | 349 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 350 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 351 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 352 | } |
michael@0 | 353 | } |
michael@0 | 354 | }, |
michael@0 | 355 | { |
michael@0 | 356 | setup: 'tshidden --vis', |
michael@0 | 357 | check: { |
michael@0 | 358 | input: 'tshidden --vis', |
michael@0 | 359 | hints: 'ible [options]', |
michael@0 | 360 | markup: 'VVVVVVVVVIIIII', |
michael@0 | 361 | status: 'ERROR', |
michael@0 | 362 | args: { |
michael@0 | 363 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 364 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 365 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 366 | } |
michael@0 | 367 | } |
michael@0 | 368 | }, |
michael@0 | 369 | { |
michael@0 | 370 | setup: 'tshidden --invisiblestrin', |
michael@0 | 371 | check: { |
michael@0 | 372 | input: 'tshidden --invisiblestrin', |
michael@0 | 373 | hints: ' [options]', |
michael@0 | 374 | markup: 'VVVVVVVVVEEEEEEEEEEEEEEEE', |
michael@0 | 375 | status: 'ERROR', |
michael@0 | 376 | args: { |
michael@0 | 377 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 378 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 379 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 380 | } |
michael@0 | 381 | } |
michael@0 | 382 | }, |
michael@0 | 383 | { |
michael@0 | 384 | setup: 'tshidden --invisiblestring', |
michael@0 | 385 | check: { |
michael@0 | 386 | input: 'tshidden --invisiblestring', |
michael@0 | 387 | hints: ' <string> [options]', |
michael@0 | 388 | markup: 'VVVVVVVVVIIIIIIIIIIIIIIIII', |
michael@0 | 389 | status: 'ERROR', |
michael@0 | 390 | args: { |
michael@0 | 391 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 392 | invisiblestring: { value: undefined, status: 'INCOMPLETE' }, |
michael@0 | 393 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 394 | } |
michael@0 | 395 | } |
michael@0 | 396 | }, |
michael@0 | 397 | { |
michael@0 | 398 | setup: 'tshidden --invisiblestring x', |
michael@0 | 399 | check: { |
michael@0 | 400 | input: 'tshidden --invisiblestring x', |
michael@0 | 401 | hints: ' [options]', |
michael@0 | 402 | markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVV', |
michael@0 | 403 | status: 'VALID', |
michael@0 | 404 | args: { |
michael@0 | 405 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 406 | invisiblestring: { value: 'x', status: 'VALID' }, |
michael@0 | 407 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 408 | } |
michael@0 | 409 | } |
michael@0 | 410 | }, |
michael@0 | 411 | { |
michael@0 | 412 | setup: 'tshidden --invisibleboolea', |
michael@0 | 413 | check: { |
michael@0 | 414 | input: 'tshidden --invisibleboolea', |
michael@0 | 415 | hints: ' [options]', |
michael@0 | 416 | markup: 'VVVVVVVVVEEEEEEEEEEEEEEEEE', |
michael@0 | 417 | status: 'ERROR', |
michael@0 | 418 | args: { |
michael@0 | 419 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 420 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 421 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 422 | } |
michael@0 | 423 | } |
michael@0 | 424 | }, |
michael@0 | 425 | { |
michael@0 | 426 | setup: 'tshidden --invisibleboolean', |
michael@0 | 427 | check: { |
michael@0 | 428 | input: 'tshidden --invisibleboolean', |
michael@0 | 429 | hints: ' [options]', |
michael@0 | 430 | markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVV', |
michael@0 | 431 | status: 'VALID', |
michael@0 | 432 | args: { |
michael@0 | 433 | visible: { value: undefined, status: 'VALID' }, |
michael@0 | 434 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 435 | invisibleboolean: { value: true, status: 'VALID' } |
michael@0 | 436 | } |
michael@0 | 437 | } |
michael@0 | 438 | }, |
michael@0 | 439 | { |
michael@0 | 440 | setup: 'tshidden --visible xxx', |
michael@0 | 441 | check: { |
michael@0 | 442 | input: 'tshidden --visible xxx', |
michael@0 | 443 | markup: 'VVVVVVVVVVVVVVVVVVVVVV', |
michael@0 | 444 | status: 'VALID', |
michael@0 | 445 | hints: '', |
michael@0 | 446 | args: { |
michael@0 | 447 | visible: { value: 'xxx', status: 'VALID' }, |
michael@0 | 448 | invisiblestring: { value: undefined, status: 'VALID' }, |
michael@0 | 449 | invisibleboolean: { value: false, status: 'VALID' } |
michael@0 | 450 | } |
michael@0 | 451 | } |
michael@0 | 452 | } |
michael@0 | 453 | ]); |
michael@0 | 454 | }; |