browser/devtools/commandline/test/browser_gcli_cli1.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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-testCli1.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.testBlank = function(options) {
michael@0 47 return helpers.audit(options, [
michael@0 48 {
michael@0 49 setup: '',
michael@0 50 check: {
michael@0 51 input: '',
michael@0 52 hints: '',
michael@0 53 markup: '',
michael@0 54 cursor: 0,
michael@0 55 current: '__command',
michael@0 56 status: 'ERROR'
michael@0 57 },
michael@0 58 post: function() {
michael@0 59 assert.is(options.requisition.commandAssignment.value, undefined);
michael@0 60 }
michael@0 61 },
michael@0 62 {
michael@0 63 setup: ' ',
michael@0 64 check: {
michael@0 65 input: ' ',
michael@0 66 hints: '',
michael@0 67 markup: 'V',
michael@0 68 cursor: 1,
michael@0 69 current: '__command',
michael@0 70 status: 'ERROR'
michael@0 71 },
michael@0 72 post: function() {
michael@0 73 assert.is(options.requisition.commandAssignment.value, undefined);
michael@0 74 }
michael@0 75 },
michael@0 76 {
michael@0 77 name: '| ',
michael@0 78 setup: function() {
michael@0 79 return helpers.setInput(options, ' ', 0);
michael@0 80 },
michael@0 81 check: {
michael@0 82 input: ' ',
michael@0 83 hints: '',
michael@0 84 markup: 'V',
michael@0 85 cursor: 0,
michael@0 86 current: '__command',
michael@0 87 status: 'ERROR'
michael@0 88 },
michael@0 89 post: function() {
michael@0 90 assert.is(options.requisition.commandAssignment.value, undefined);
michael@0 91 }
michael@0 92 }
michael@0 93 ]);
michael@0 94 };
michael@0 95
michael@0 96 exports.testDelete = function(options) {
michael@0 97 return helpers.audit(options, [
michael@0 98 {
michael@0 99 setup: 'x<BACKSPACE>',
michael@0 100 check: {
michael@0 101 input: '',
michael@0 102 hints: '',
michael@0 103 markup: '',
michael@0 104 cursor: 0,
michael@0 105 current: '__command',
michael@0 106 status: 'ERROR'
michael@0 107 },
michael@0 108 post: function() {
michael@0 109 assert.is(options.requisition.commandAssignment.value, undefined);
michael@0 110 }
michael@0 111 }
michael@0 112 ]);
michael@0 113 };
michael@0 114
michael@0 115 exports.testIncompleteMultiMatch = function(options) {
michael@0 116 return helpers.audit(options, [
michael@0 117 {
michael@0 118 setup: 'tsn ex',
michael@0 119 check: {
michael@0 120 input: 'tsn ex',
michael@0 121 hints: 't',
michael@0 122 markup: 'IIIVII',
michael@0 123 cursor: 6,
michael@0 124 current: '__command',
michael@0 125 status: 'ERROR',
michael@0 126 predictionsContains: [
michael@0 127 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend'
michael@0 128 ]
michael@0 129 }
michael@0 130 }
michael@0 131 ]);
michael@0 132 };
michael@0 133
michael@0 134 exports.testIncompleteSingleMatch = function(options) {
michael@0 135 return helpers.audit(options, [
michael@0 136 {
michael@0 137 setup: 'tselar',
michael@0 138 check: {
michael@0 139 input: 'tselar',
michael@0 140 hints: 'r',
michael@0 141 markup: 'IIIIII',
michael@0 142 cursor: 6,
michael@0 143 current: '__command',
michael@0 144 status: 'ERROR',
michael@0 145 predictions: [ 'tselarr' ],
michael@0 146 unassigned: [ ]
michael@0 147 }
michael@0 148 }
michael@0 149 ]);
michael@0 150 };
michael@0 151
michael@0 152 exports.testTsv = function(options) {
michael@0 153 return helpers.audit(options, [
michael@0 154 {
michael@0 155 setup: 'tsv',
michael@0 156 check: {
michael@0 157 input: 'tsv',
michael@0 158 hints: ' <optionType> <optionValue>',
michael@0 159 markup: 'VVV',
michael@0 160 cursor: 3,
michael@0 161 current: '__command',
michael@0 162 status: 'ERROR',
michael@0 163 predictions: [ ],
michael@0 164 unassigned: [ ],
michael@0 165 args: {
michael@0 166 command: { name: 'tsv' },
michael@0 167 optionType: { arg: '', status: 'INCOMPLETE' },
michael@0 168 optionValue: { arg: '', status: 'INCOMPLETE' }
michael@0 169 }
michael@0 170 }
michael@0 171 },
michael@0 172 {
michael@0 173 setup: 'tsv ',
michael@0 174 check: {
michael@0 175 input: 'tsv ',
michael@0 176 hints: 'option1 <optionValue>',
michael@0 177 markup: 'VVVV',
michael@0 178 cursor: 4,
michael@0 179 current: 'optionType',
michael@0 180 status: 'ERROR',
michael@0 181 predictions: [ 'option1', 'option2', 'option3' ],
michael@0 182 unassigned: [ ],
michael@0 183 tooltipState: 'true:importantFieldFlag',
michael@0 184 args: {
michael@0 185 command: { name: 'tsv' },
michael@0 186 optionType: { arg: '', status: 'INCOMPLETE' },
michael@0 187 optionValue: { arg: '', status: 'INCOMPLETE' }
michael@0 188 }
michael@0 189 }
michael@0 190 },
michael@0 191 {
michael@0 192 name: 'ts|v',
michael@0 193 setup: function() {
michael@0 194 return helpers.setInput(options, 'tsv ', 2);
michael@0 195 },
michael@0 196 check: {
michael@0 197 input: 'tsv ',
michael@0 198 hints: '<optionType> <optionValue>',
michael@0 199 markup: 'VVVV',
michael@0 200 cursor: 2,
michael@0 201 current: '__command',
michael@0 202 status: 'ERROR',
michael@0 203 predictions: [ ],
michael@0 204 unassigned: [ ],
michael@0 205 args: {
michael@0 206 command: { name: 'tsv' },
michael@0 207 optionType: { arg: '', status: 'INCOMPLETE' },
michael@0 208 optionValue: { arg: '', status: 'INCOMPLETE' }
michael@0 209 }
michael@0 210 }
michael@0 211 },
michael@0 212 {
michael@0 213 setup: 'tsv o',
michael@0 214 check: {
michael@0 215 input: 'tsv o',
michael@0 216 hints: 'ption1 <optionValue>',
michael@0 217 markup: 'VVVVI',
michael@0 218 cursor: 5,
michael@0 219 current: 'optionType',
michael@0 220 status: 'ERROR',
michael@0 221 predictions: [ 'option1', 'option2', 'option3' ],
michael@0 222 unassigned: [ ],
michael@0 223 tooltipState: 'true:importantFieldFlag',
michael@0 224 args: {
michael@0 225 command: { name: 'tsv' },
michael@0 226 optionType: {
michael@0 227 value: undefined,
michael@0 228 arg: ' o',
michael@0 229 status: 'INCOMPLETE',
michael@0 230 message: 'Value required for \'optionType\'.'
michael@0 231 },
michael@0 232 optionValue: {
michael@0 233 value: undefined,
michael@0 234 arg: '',
michael@0 235 status: 'INCOMPLETE',
michael@0 236 message: 'Value required for \'optionValue\'.'
michael@0 237 }
michael@0 238 }
michael@0 239 }
michael@0 240 },
michael@0 241 {
michael@0 242 setup: 'tsv option',
michael@0 243 check: {
michael@0 244 input: 'tsv option',
michael@0 245 hints: '1 <optionValue>',
michael@0 246 markup: 'VVVVIIIIII',
michael@0 247 cursor: 10,
michael@0 248 current: 'optionType',
michael@0 249 status: 'ERROR',
michael@0 250 predictions: [ 'option1', 'option2', 'option3' ],
michael@0 251 unassigned: [ ],
michael@0 252 tooltipState: 'true:importantFieldFlag',
michael@0 253 args: {
michael@0 254 command: { name: 'tsv' },
michael@0 255 optionType: {
michael@0 256 value: undefined,
michael@0 257 arg: ' option',
michael@0 258 status: 'INCOMPLETE',
michael@0 259 message: 'Value required for \'optionType\'.'
michael@0 260 },
michael@0 261 optionValue: {
michael@0 262 value: undefined,
michael@0 263 arg: '',
michael@0 264 status: 'INCOMPLETE',
michael@0 265 message: 'Value required for \'optionValue\'.'
michael@0 266 }
michael@0 267 }
michael@0 268 }
michael@0 269 },
michael@0 270 {
michael@0 271 skipRemainingIf: options.isNoDom,
michael@0 272 name: '|tsv option',
michael@0 273 setup: function() {
michael@0 274 return helpers.setInput(options, 'tsv option', 0);
michael@0 275 },
michael@0 276 check: {
michael@0 277 input: 'tsv option',
michael@0 278 hints: ' <optionValue>',
michael@0 279 markup: 'VVVVEEEEEE',
michael@0 280 cursor: 0,
michael@0 281 current: '__command',
michael@0 282 status: 'ERROR',
michael@0 283 predictions: [ ],
michael@0 284 unassigned: [ ],
michael@0 285 args: {
michael@0 286 command: { name: 'tsv' },
michael@0 287 optionType: {
michael@0 288 value: undefined,
michael@0 289 arg: ' option',
michael@0 290 status: 'INCOMPLETE',
michael@0 291 message: 'Value required for \'optionType\'.'
michael@0 292 },
michael@0 293 optionValue: {
michael@0 294 value: undefined,
michael@0 295 arg: '',
michael@0 296 status: 'INCOMPLETE',
michael@0 297 message: 'Value required for \'optionValue\'.'
michael@0 298 }
michael@0 299 }
michael@0 300 }
michael@0 301 },
michael@0 302 {
michael@0 303 setup: 'tsv option ',
michael@0 304 check: {
michael@0 305 input: 'tsv option ',
michael@0 306 hints: '<optionValue>',
michael@0 307 markup: 'VVVVEEEEEEV',
michael@0 308 cursor: 11,
michael@0 309 current: 'optionValue',
michael@0 310 status: 'ERROR',
michael@0 311 predictions: [ ],
michael@0 312 unassigned: [ ],
michael@0 313 tooltipState: 'false:default',
michael@0 314 args: {
michael@0 315 command: { name: 'tsv' },
michael@0 316 optionType: {
michael@0 317 value: undefined,
michael@0 318 arg: ' option ',
michael@0 319 status: 'ERROR',
michael@0 320 message: 'Can\'t use \'option\'.'
michael@0 321 },
michael@0 322 optionValue: {
michael@0 323 value: undefined,
michael@0 324 arg: '',
michael@0 325 status: 'INCOMPLETE',
michael@0 326 message: 'Value required for \'optionValue\'.'
michael@0 327 }
michael@0 328 }
michael@0 329 }
michael@0 330 },
michael@0 331 {
michael@0 332 setup: 'tsv option1',
michael@0 333 check: {
michael@0 334 input: 'tsv option1',
michael@0 335 hints: ' <optionValue>',
michael@0 336 markup: 'VVVVVVVVVVV',
michael@0 337 cursor: 11,
michael@0 338 current: 'optionType',
michael@0 339 status: 'ERROR',
michael@0 340 predictions: [ 'option1' ],
michael@0 341 unassigned: [ ],
michael@0 342 tooltipState: 'true:importantFieldFlag',
michael@0 343 args: {
michael@0 344 command: { name: 'tsv' },
michael@0 345 optionType: {
michael@0 346 value: 'string',
michael@0 347 arg: ' option1',
michael@0 348 status: 'VALID',
michael@0 349 message: ''
michael@0 350 },
michael@0 351 optionValue: {
michael@0 352 value: undefined,
michael@0 353 arg: '',
michael@0 354 status: 'INCOMPLETE',
michael@0 355 message: 'Value required for \'optionValue\'.'
michael@0 356 }
michael@0 357 }
michael@0 358 }
michael@0 359 },
michael@0 360 {
michael@0 361 setup: 'tsv option1 ',
michael@0 362 check: {
michael@0 363 input: 'tsv option1 ',
michael@0 364 hints: '<optionValue>',
michael@0 365 markup: 'VVVVVVVVVVVV',
michael@0 366 cursor: 12,
michael@0 367 current: 'optionValue',
michael@0 368 status: 'ERROR',
michael@0 369 predictions: [ ],
michael@0 370 unassigned: [ ],
michael@0 371 args: {
michael@0 372 command: { name: 'tsv' },
michael@0 373 optionType: {
michael@0 374 value: 'string',
michael@0 375 arg: ' option1 ',
michael@0 376 status: 'VALID',
michael@0 377 message: ''
michael@0 378 },
michael@0 379 optionValue: {
michael@0 380 value: undefined,
michael@0 381 arg: '',
michael@0 382 status: 'INCOMPLETE',
michael@0 383 message: 'Value required for \'optionValue\'.'
michael@0 384 }
michael@0 385 }
michael@0 386 }
michael@0 387 },
michael@0 388 {
michael@0 389 setup: 'tsv option2',
michael@0 390 check: {
michael@0 391 input: 'tsv option2',
michael@0 392 hints: ' <optionValue>',
michael@0 393 markup: 'VVVVVVVVVVV',
michael@0 394 cursor: 11,
michael@0 395 current: 'optionType',
michael@0 396 status: 'ERROR',
michael@0 397 predictions: [ 'option2' ],
michael@0 398 unassigned: [ ],
michael@0 399 tooltipState: 'true:importantFieldFlag',
michael@0 400 args: {
michael@0 401 command: { name: 'tsv' },
michael@0 402 optionType: {
michael@0 403 value: 'number',
michael@0 404 arg: ' option2',
michael@0 405 status: 'VALID',
michael@0 406 message: ''
michael@0 407 },
michael@0 408 optionValue: {
michael@0 409 value: undefined,
michael@0 410 arg: '',
michael@0 411 status: 'INCOMPLETE',
michael@0 412 message: 'Value required for \'optionValue\'.'
michael@0 413 }
michael@0 414 }
michael@0 415 }
michael@0 416 }
michael@0 417 ]);
michael@0 418 };
michael@0 419
michael@0 420 exports.testTsvValues = function(options) {
michael@0 421 return helpers.audit(options, [
michael@0 422 {
michael@0 423 setup: 'tsv option1 6',
michael@0 424 check: {
michael@0 425 input: 'tsv option1 6',
michael@0 426 hints: '',
michael@0 427 markup: 'VVVVVVVVVVVVV',
michael@0 428 cursor: 13,
michael@0 429 current: 'optionValue',
michael@0 430 status: 'VALID',
michael@0 431 predictions: [ ],
michael@0 432 unassigned: [ ],
michael@0 433 args: {
michael@0 434 command: { name: 'tsv' },
michael@0 435 optionType: {
michael@0 436 value: 'string',
michael@0 437 arg: ' option1',
michael@0 438 status: 'VALID',
michael@0 439 message: ''
michael@0 440 },
michael@0 441 optionValue: {
michael@0 442 arg: ' 6',
michael@0 443 status: 'VALID',
michael@0 444 message: ''
michael@0 445 }
michael@0 446 }
michael@0 447 }
michael@0 448 },
michael@0 449 {
michael@0 450 setup: 'tsv option2 6',
michael@0 451 check: {
michael@0 452 input: 'tsv option2 6',
michael@0 453 hints: '',
michael@0 454 markup: 'VVVVVVVVVVVVV',
michael@0 455 cursor: 13,
michael@0 456 current: 'optionValue',
michael@0 457 status: 'VALID',
michael@0 458 predictions: [ ],
michael@0 459 unassigned: [ ],
michael@0 460 args: {
michael@0 461 command: { name: 'tsv' },
michael@0 462 optionType: {
michael@0 463 value: 'number',
michael@0 464 arg: ' option2',
michael@0 465 status: 'VALID',
michael@0 466 message: ''
michael@0 467 },
michael@0 468 optionValue: {
michael@0 469 arg: ' 6',
michael@0 470 status: 'VALID',
michael@0 471 message: ''
michael@0 472 }
michael@0 473 }
michael@0 474 }
michael@0 475 },
michael@0 476 // Delegated remote types can't transfer value types so we only test for
michael@0 477 // the value of 'value' when we're local
michael@0 478 {
michael@0 479 skipIf: options.isRemote,
michael@0 480 setup: 'tsv option1 6',
michael@0 481 check: {
michael@0 482 args: {
michael@0 483 optionValue: { value: '6' }
michael@0 484 }
michael@0 485 }
michael@0 486 },
michael@0 487 {
michael@0 488 skipIf: options.isRemote,
michael@0 489 setup: 'tsv option2 6',
michael@0 490 check: {
michael@0 491 args: {
michael@0 492 optionValue: { value: 6 }
michael@0 493 }
michael@0 494 }
michael@0 495 }
michael@0 496 ]);
michael@0 497 };
michael@0 498
michael@0 499 exports.testInvalid = function(options) {
michael@0 500 return helpers.audit(options, [
michael@0 501 {
michael@0 502 setup: 'zxjq',
michael@0 503 check: {
michael@0 504 input: 'zxjq',
michael@0 505 hints: '',
michael@0 506 markup: 'EEEE',
michael@0 507 cursor: 4,
michael@0 508 current: '__command',
michael@0 509 status: 'ERROR',
michael@0 510 predictions: [ ],
michael@0 511 unassigned: [ ],
michael@0 512 tooltipState: 'true:isError'
michael@0 513 }
michael@0 514 },
michael@0 515 {
michael@0 516 setup: 'zxjq ',
michael@0 517 check: {
michael@0 518 input: 'zxjq ',
michael@0 519 hints: '',
michael@0 520 markup: 'EEEEV',
michael@0 521 cursor: 5,
michael@0 522 current: '__command',
michael@0 523 status: 'ERROR',
michael@0 524 predictions: [ ],
michael@0 525 unassigned: [ ],
michael@0 526 tooltipState: 'true:isError'
michael@0 527 }
michael@0 528 },
michael@0 529 {
michael@0 530 setup: 'zxjq one',
michael@0 531 check: {
michael@0 532 input: 'zxjq one',
michael@0 533 hints: '',
michael@0 534 markup: 'EEEEVEEE',
michael@0 535 cursor: 8,
michael@0 536 current: '__unassigned',
michael@0 537 status: 'ERROR',
michael@0 538 predictions: [ ],
michael@0 539 unassigned: [ ' one' ],
michael@0 540 tooltipState: 'true:isError'
michael@0 541 }
michael@0 542 }
michael@0 543 ]);
michael@0 544 };

mercurial