browser/devtools/commandline/test/browser_gcli_cli1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/commandline/test/browser_gcli_cli1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,544 @@
     1.4 +/*
     1.5 + * Copyright 2012, Mozilla Foundation and contributors
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + * http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +'use strict';
    1.21 +// <INJECTED SOURCE:START>
    1.22 +
    1.23 +// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
    1.24 +// DO NOT EDIT IT DIRECTLY
    1.25 +
    1.26 +var exports = {};
    1.27 +
    1.28 +var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testCli1.js</p>";
    1.29 +
    1.30 +function test() {
    1.31 +  return Task.spawn(function() {
    1.32 +    let options = yield helpers.openTab(TEST_URI);
    1.33 +    yield helpers.openToolbar(options);
    1.34 +    gcli.addItems(mockCommands.items);
    1.35 +
    1.36 +    yield helpers.runTests(options, exports);
    1.37 +
    1.38 +    gcli.removeItems(mockCommands.items);
    1.39 +    yield helpers.closeToolbar(options);
    1.40 +    yield helpers.closeTab(options);
    1.41 +  }).then(finish, helpers.handleError);
    1.42 +}
    1.43 +
    1.44 +// <INJECTED SOURCE:END>
    1.45 +
    1.46 +// var assert = require('../testharness/assert');
    1.47 +// var helpers = require('./helpers');
    1.48 +
    1.49 +exports.testBlank = function(options) {
    1.50 +  return helpers.audit(options, [
    1.51 +    {
    1.52 +      setup:    '',
    1.53 +      check: {
    1.54 +        input:  '',
    1.55 +        hints:  '',
    1.56 +        markup: '',
    1.57 +        cursor: 0,
    1.58 +        current: '__command',
    1.59 +        status: 'ERROR'
    1.60 +      },
    1.61 +      post: function() {
    1.62 +        assert.is(options.requisition.commandAssignment.value, undefined);
    1.63 +      }
    1.64 +    },
    1.65 +    {
    1.66 +      setup:    ' ',
    1.67 +      check: {
    1.68 +        input:  ' ',
    1.69 +        hints:   '',
    1.70 +        markup: 'V',
    1.71 +        cursor: 1,
    1.72 +        current: '__command',
    1.73 +        status: 'ERROR'
    1.74 +      },
    1.75 +      post: function() {
    1.76 +        assert.is(options.requisition.commandAssignment.value, undefined);
    1.77 +      }
    1.78 +    },
    1.79 +    {
    1.80 +      name: '| ',
    1.81 +      setup: function() {
    1.82 +        return helpers.setInput(options, ' ', 0);
    1.83 +      },
    1.84 +      check: {
    1.85 +        input:  ' ',
    1.86 +        hints:   '',
    1.87 +        markup: 'V',
    1.88 +        cursor: 0,
    1.89 +        current: '__command',
    1.90 +        status: 'ERROR'
    1.91 +      },
    1.92 +      post: function() {
    1.93 +        assert.is(options.requisition.commandAssignment.value, undefined);
    1.94 +      }
    1.95 +    }
    1.96 +  ]);
    1.97 +};
    1.98 +
    1.99 +exports.testDelete = function(options) {
   1.100 +  return helpers.audit(options, [
   1.101 +    {
   1.102 +      setup:    'x<BACKSPACE>',
   1.103 +      check: {
   1.104 +        input:  '',
   1.105 +        hints:  '',
   1.106 +        markup: '',
   1.107 +        cursor: 0,
   1.108 +        current: '__command',
   1.109 +        status: 'ERROR'
   1.110 +      },
   1.111 +      post: function() {
   1.112 +        assert.is(options.requisition.commandAssignment.value, undefined);
   1.113 +      }
   1.114 +    }
   1.115 +  ]);
   1.116 +};
   1.117 +
   1.118 +exports.testIncompleteMultiMatch = function(options) {
   1.119 +  return helpers.audit(options, [
   1.120 +    {
   1.121 +      setup:    'tsn ex',
   1.122 +      check: {
   1.123 +        input:  'tsn ex',
   1.124 +        hints:        't',
   1.125 +        markup: 'IIIVII',
   1.126 +        cursor: 6,
   1.127 +        current: '__command',
   1.128 +        status: 'ERROR',
   1.129 +        predictionsContains: [
   1.130 +          'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend'
   1.131 +        ]
   1.132 +      }
   1.133 +    }
   1.134 +  ]);
   1.135 +};
   1.136 +
   1.137 +exports.testIncompleteSingleMatch = function(options) {
   1.138 +  return helpers.audit(options, [
   1.139 +    {
   1.140 +      setup:    'tselar',
   1.141 +      check: {
   1.142 +        input:  'tselar',
   1.143 +        hints:        'r',
   1.144 +        markup: 'IIIIII',
   1.145 +        cursor: 6,
   1.146 +        current: '__command',
   1.147 +        status: 'ERROR',
   1.148 +        predictions: [ 'tselarr' ],
   1.149 +        unassigned: [ ]
   1.150 +      }
   1.151 +    }
   1.152 +  ]);
   1.153 +};
   1.154 +
   1.155 +exports.testTsv = function(options) {
   1.156 +  return helpers.audit(options, [
   1.157 +    {
   1.158 +      setup:    'tsv',
   1.159 +      check: {
   1.160 +        input:  'tsv',
   1.161 +        hints:     ' <optionType> <optionValue>',
   1.162 +        markup: 'VVV',
   1.163 +        cursor: 3,
   1.164 +        current: '__command',
   1.165 +        status: 'ERROR',
   1.166 +        predictions: [ ],
   1.167 +        unassigned: [ ],
   1.168 +        args: {
   1.169 +          command: { name: 'tsv' },
   1.170 +          optionType: { arg: '', status: 'INCOMPLETE' },
   1.171 +          optionValue: { arg: '', status: 'INCOMPLETE' }
   1.172 +        }
   1.173 +      }
   1.174 +    },
   1.175 +    {
   1.176 +      setup:    'tsv ',
   1.177 +      check: {
   1.178 +        input:  'tsv ',
   1.179 +        hints:      'option1 <optionValue>',
   1.180 +        markup: 'VVVV',
   1.181 +        cursor: 4,
   1.182 +        current: 'optionType',
   1.183 +        status: 'ERROR',
   1.184 +        predictions: [ 'option1', 'option2', 'option3' ],
   1.185 +        unassigned: [ ],
   1.186 +        tooltipState: 'true:importantFieldFlag',
   1.187 +        args: {
   1.188 +          command: { name: 'tsv' },
   1.189 +          optionType: { arg: '', status: 'INCOMPLETE' },
   1.190 +          optionValue: { arg: '', status: 'INCOMPLETE' }
   1.191 +        }
   1.192 +      }
   1.193 +    },
   1.194 +    {
   1.195 +      name: 'ts|v',
   1.196 +      setup: function() {
   1.197 +        return helpers.setInput(options, 'tsv ', 2);
   1.198 +      },
   1.199 +      check: {
   1.200 +        input:  'tsv ',
   1.201 +        hints:      '<optionType> <optionValue>',
   1.202 +        markup: 'VVVV',
   1.203 +        cursor: 2,
   1.204 +        current: '__command',
   1.205 +        status: 'ERROR',
   1.206 +        predictions: [ ],
   1.207 +        unassigned: [ ],
   1.208 +        args: {
   1.209 +          command: { name: 'tsv' },
   1.210 +          optionType: { arg: '', status: 'INCOMPLETE' },
   1.211 +          optionValue: { arg: '', status: 'INCOMPLETE' }
   1.212 +        }
   1.213 +      }
   1.214 +    },
   1.215 +    {
   1.216 +      setup:    'tsv o',
   1.217 +      check: {
   1.218 +        input:  'tsv o',
   1.219 +        hints:       'ption1 <optionValue>',
   1.220 +        markup: 'VVVVI',
   1.221 +        cursor: 5,
   1.222 +        current: 'optionType',
   1.223 +        status: 'ERROR',
   1.224 +        predictions: [ 'option1', 'option2', 'option3' ],
   1.225 +        unassigned: [ ],
   1.226 +        tooltipState: 'true:importantFieldFlag',
   1.227 +        args: {
   1.228 +          command: { name: 'tsv' },
   1.229 +          optionType: {
   1.230 +            value: undefined,
   1.231 +            arg: ' o',
   1.232 +            status: 'INCOMPLETE',
   1.233 +            message: 'Value required for \'optionType\'.'
   1.234 +          },
   1.235 +          optionValue: {
   1.236 +            value: undefined,
   1.237 +            arg: '',
   1.238 +            status: 'INCOMPLETE',
   1.239 +            message: 'Value required for \'optionValue\'.'
   1.240 +          }
   1.241 +        }
   1.242 +      }
   1.243 +    },
   1.244 +    {
   1.245 +      setup:    'tsv option',
   1.246 +      check: {
   1.247 +        input:  'tsv option',
   1.248 +        hints:            '1 <optionValue>',
   1.249 +        markup: 'VVVVIIIIII',
   1.250 +        cursor: 10,
   1.251 +        current: 'optionType',
   1.252 +        status: 'ERROR',
   1.253 +        predictions: [ 'option1', 'option2', 'option3' ],
   1.254 +        unassigned: [ ],
   1.255 +        tooltipState: 'true:importantFieldFlag',
   1.256 +        args: {
   1.257 +          command: { name: 'tsv' },
   1.258 +          optionType: {
   1.259 +            value: undefined,
   1.260 +            arg: ' option',
   1.261 +            status: 'INCOMPLETE',
   1.262 +            message: 'Value required for \'optionType\'.'
   1.263 +          },
   1.264 +          optionValue: {
   1.265 +            value: undefined,
   1.266 +            arg: '',
   1.267 +            status: 'INCOMPLETE',
   1.268 +            message: 'Value required for \'optionValue\'.'
   1.269 +          }
   1.270 +        }
   1.271 +      }
   1.272 +    },
   1.273 +    {
   1.274 +      skipRemainingIf: options.isNoDom,
   1.275 +      name: '|tsv option',
   1.276 +      setup: function() {
   1.277 +        return helpers.setInput(options, 'tsv option', 0);
   1.278 +      },
   1.279 +      check: {
   1.280 +        input:  'tsv option',
   1.281 +        hints:            ' <optionValue>',
   1.282 +        markup: 'VVVVEEEEEE',
   1.283 +        cursor: 0,
   1.284 +        current: '__command',
   1.285 +        status: 'ERROR',
   1.286 +        predictions: [ ],
   1.287 +        unassigned: [ ],
   1.288 +        args: {
   1.289 +          command: { name: 'tsv' },
   1.290 +          optionType: {
   1.291 +            value: undefined,
   1.292 +            arg: ' option',
   1.293 +            status: 'INCOMPLETE',
   1.294 +            message: 'Value required for \'optionType\'.'
   1.295 +          },
   1.296 +          optionValue: {
   1.297 +            value: undefined,
   1.298 +            arg: '',
   1.299 +            status: 'INCOMPLETE',
   1.300 +            message: 'Value required for \'optionValue\'.'
   1.301 +          }
   1.302 +        }
   1.303 +      }
   1.304 +    },
   1.305 +    {
   1.306 +      setup:    'tsv option ',
   1.307 +      check: {
   1.308 +        input:  'tsv option ',
   1.309 +        hints:             '<optionValue>',
   1.310 +        markup: 'VVVVEEEEEEV',
   1.311 +        cursor: 11,
   1.312 +        current: 'optionValue',
   1.313 +        status: 'ERROR',
   1.314 +        predictions: [ ],
   1.315 +        unassigned: [ ],
   1.316 +        tooltipState: 'false:default',
   1.317 +        args: {
   1.318 +          command: { name: 'tsv' },
   1.319 +          optionType: {
   1.320 +            value: undefined,
   1.321 +            arg: ' option ',
   1.322 +            status: 'ERROR',
   1.323 +            message: 'Can\'t use \'option\'.'
   1.324 +          },
   1.325 +          optionValue: {
   1.326 +            value: undefined,
   1.327 +            arg: '',
   1.328 +            status: 'INCOMPLETE',
   1.329 +            message: 'Value required for \'optionValue\'.'
   1.330 +          }
   1.331 +        }
   1.332 +      }
   1.333 +    },
   1.334 +    {
   1.335 +      setup:    'tsv option1',
   1.336 +      check: {
   1.337 +        input:  'tsv option1',
   1.338 +        hints:             ' <optionValue>',
   1.339 +        markup: 'VVVVVVVVVVV',
   1.340 +        cursor: 11,
   1.341 +        current: 'optionType',
   1.342 +        status: 'ERROR',
   1.343 +        predictions: [ 'option1' ],
   1.344 +        unassigned: [ ],
   1.345 +        tooltipState: 'true:importantFieldFlag',
   1.346 +        args: {
   1.347 +          command: { name: 'tsv' },
   1.348 +          optionType: {
   1.349 +            value: 'string',
   1.350 +            arg: ' option1',
   1.351 +            status: 'VALID',
   1.352 +            message: ''
   1.353 +          },
   1.354 +          optionValue: {
   1.355 +            value: undefined,
   1.356 +            arg: '',
   1.357 +            status: 'INCOMPLETE',
   1.358 +            message: 'Value required for \'optionValue\'.'
   1.359 +          }
   1.360 +        }
   1.361 +      }
   1.362 +    },
   1.363 +    {
   1.364 +      setup:    'tsv option1 ',
   1.365 +      check: {
   1.366 +        input:  'tsv option1 ',
   1.367 +        hints:              '<optionValue>',
   1.368 +        markup: 'VVVVVVVVVVVV',
   1.369 +        cursor: 12,
   1.370 +        current: 'optionValue',
   1.371 +        status: 'ERROR',
   1.372 +        predictions: [ ],
   1.373 +        unassigned: [ ],
   1.374 +        args: {
   1.375 +          command: { name: 'tsv' },
   1.376 +          optionType: {
   1.377 +            value: 'string',
   1.378 +            arg: ' option1 ',
   1.379 +            status: 'VALID',
   1.380 +            message: ''
   1.381 +          },
   1.382 +          optionValue: {
   1.383 +            value: undefined,
   1.384 +            arg: '',
   1.385 +            status: 'INCOMPLETE',
   1.386 +            message: 'Value required for \'optionValue\'.'
   1.387 +          }
   1.388 +        }
   1.389 +      }
   1.390 +    },
   1.391 +    {
   1.392 +      setup:    'tsv option2',
   1.393 +      check: {
   1.394 +        input:  'tsv option2',
   1.395 +        hints:             ' <optionValue>',
   1.396 +        markup: 'VVVVVVVVVVV',
   1.397 +        cursor: 11,
   1.398 +        current: 'optionType',
   1.399 +        status: 'ERROR',
   1.400 +        predictions: [ 'option2' ],
   1.401 +        unassigned: [ ],
   1.402 +        tooltipState: 'true:importantFieldFlag',
   1.403 +        args: {
   1.404 +          command: { name: 'tsv' },
   1.405 +          optionType: {
   1.406 +            value: 'number',
   1.407 +            arg: ' option2',
   1.408 +            status: 'VALID',
   1.409 +            message: ''
   1.410 +          },
   1.411 +          optionValue: {
   1.412 +            value: undefined,
   1.413 +            arg: '',
   1.414 +            status: 'INCOMPLETE',
   1.415 +            message: 'Value required for \'optionValue\'.'
   1.416 +          }
   1.417 +        }
   1.418 +      }
   1.419 +    }
   1.420 +  ]);
   1.421 +};
   1.422 +
   1.423 +exports.testTsvValues = function(options) {
   1.424 +  return helpers.audit(options, [
   1.425 +    {
   1.426 +      setup:    'tsv option1 6',
   1.427 +      check: {
   1.428 +        input:  'tsv option1 6',
   1.429 +        hints:               '',
   1.430 +        markup: 'VVVVVVVVVVVVV',
   1.431 +        cursor: 13,
   1.432 +        current: 'optionValue',
   1.433 +        status: 'VALID',
   1.434 +        predictions: [ ],
   1.435 +        unassigned: [ ],
   1.436 +        args: {
   1.437 +          command: { name: 'tsv' },
   1.438 +          optionType: {
   1.439 +            value: 'string',
   1.440 +            arg: ' option1',
   1.441 +            status: 'VALID',
   1.442 +            message: ''
   1.443 +          },
   1.444 +          optionValue: {
   1.445 +            arg: ' 6',
   1.446 +            status: 'VALID',
   1.447 +            message: ''
   1.448 +          }
   1.449 +        }
   1.450 +      }
   1.451 +    },
   1.452 +    {
   1.453 +      setup:    'tsv option2 6',
   1.454 +      check: {
   1.455 +        input:  'tsv option2 6',
   1.456 +        hints:               '',
   1.457 +        markup: 'VVVVVVVVVVVVV',
   1.458 +        cursor: 13,
   1.459 +        current: 'optionValue',
   1.460 +        status: 'VALID',
   1.461 +        predictions: [ ],
   1.462 +        unassigned: [ ],
   1.463 +        args: {
   1.464 +          command: { name: 'tsv' },
   1.465 +          optionType: {
   1.466 +            value: 'number',
   1.467 +            arg: ' option2',
   1.468 +            status: 'VALID',
   1.469 +            message: ''
   1.470 +          },
   1.471 +          optionValue: {
   1.472 +            arg: ' 6',
   1.473 +            status: 'VALID',
   1.474 +            message: ''
   1.475 +          }
   1.476 +        }
   1.477 +      }
   1.478 +    },
   1.479 +    // Delegated remote types can't transfer value types so we only test for
   1.480 +    // the value of 'value' when we're local
   1.481 +    {
   1.482 +      skipIf: options.isRemote,
   1.483 +      setup: 'tsv option1 6',
   1.484 +      check: {
   1.485 +        args: {
   1.486 +          optionValue: { value: '6' }
   1.487 +        }
   1.488 +      }
   1.489 +    },
   1.490 +    {
   1.491 +      skipIf: options.isRemote,
   1.492 +      setup: 'tsv option2 6',
   1.493 +      check: {
   1.494 +        args: {
   1.495 +          optionValue: { value: 6 }
   1.496 +        }
   1.497 +      }
   1.498 +    }
   1.499 +  ]);
   1.500 +};
   1.501 +
   1.502 +exports.testInvalid = function(options) {
   1.503 +  return helpers.audit(options, [
   1.504 +    {
   1.505 +      setup:    'zxjq',
   1.506 +      check: {
   1.507 +        input:  'zxjq',
   1.508 +        hints:      '',
   1.509 +        markup: 'EEEE',
   1.510 +        cursor: 4,
   1.511 +        current: '__command',
   1.512 +        status: 'ERROR',
   1.513 +        predictions: [ ],
   1.514 +        unassigned: [ ],
   1.515 +        tooltipState: 'true:isError'
   1.516 +      }
   1.517 +    },
   1.518 +    {
   1.519 +      setup:    'zxjq ',
   1.520 +      check: {
   1.521 +        input:  'zxjq ',
   1.522 +        hints:       '',
   1.523 +        markup: 'EEEEV',
   1.524 +        cursor: 5,
   1.525 +        current: '__command',
   1.526 +        status: 'ERROR',
   1.527 +        predictions: [ ],
   1.528 +        unassigned: [ ],
   1.529 +        tooltipState: 'true:isError'
   1.530 +      }
   1.531 +    },
   1.532 +    {
   1.533 +      setup:    'zxjq one',
   1.534 +      check: {
   1.535 +        input:  'zxjq one',
   1.536 +        hints:          '',
   1.537 +        markup: 'EEEEVEEE',
   1.538 +        cursor: 8,
   1.539 +        current: '__unassigned',
   1.540 +        status: 'ERROR',
   1.541 +        predictions: [ ],
   1.542 +        unassigned: [ ' one' ],
   1.543 +        tooltipState: 'true:isError'
   1.544 +      }
   1.545 +    }
   1.546 +  ]);
   1.547 +};

mercurial