browser/devtools/commandline/test/browser_gcli_context.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_context.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,254 @@
     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-testContext.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 helpers = require('./helpers');
    1.47 +
    1.48 +exports.testBaseline = function(options) {
    1.49 +  return helpers.audit(options, [
    1.50 +    // These 3 establish a baseline for comparison when we have used the
    1.51 +    // context command
    1.52 +    {
    1.53 +      setup:    'ext',
    1.54 +      check: {
    1.55 +        input:  'ext',
    1.56 +        hints:     ' -> context',
    1.57 +        markup: 'III',
    1.58 +        message: '',
    1.59 +        predictions: [ 'context', 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ],
    1.60 +        unassigned: [ ],
    1.61 +      }
    1.62 +    },
    1.63 +    {
    1.64 +      setup:    'ext test',
    1.65 +      check: {
    1.66 +        input:  'ext test',
    1.67 +        hints:          '',
    1.68 +        markup: 'IIIVEEEE',
    1.69 +        status: 'ERROR',
    1.70 +        message: 'Too many arguments',
    1.71 +        unassigned: [ ' test' ],
    1.72 +      }
    1.73 +    },
    1.74 +    {
    1.75 +      setup:    'tsn',
    1.76 +      check: {
    1.77 +        input:  'tsn',
    1.78 +        hints:     ' deep down nested cmd',
    1.79 +        markup: 'III',
    1.80 +        cursor: 3,
    1.81 +        current: '__command',
    1.82 +        status: 'ERROR',
    1.83 +        predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ],
    1.84 +        args: {
    1.85 +          command: { name: 'tsn' },
    1.86 +        }
    1.87 +      }
    1.88 +    }
    1.89 +  ]);
    1.90 +};
    1.91 +
    1.92 +exports.testContext = function(options) {
    1.93 +  return helpers.audit(options, [
    1.94 +    // Use the 'tsn' context
    1.95 +    {
    1.96 +      setup:    'context tsn',
    1.97 +      check: {
    1.98 +        input:  'context tsn',
    1.99 +        hints:             ' deep down nested cmd',
   1.100 +        markup: 'VVVVVVVVVVV',
   1.101 +        message: '',
   1.102 +        predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ],
   1.103 +        args: {
   1.104 +          command: { name: 'context' },
   1.105 +          prefix: {
   1.106 +            value: options.requisition.canon.getCommand('tsn'),
   1.107 +            status: 'VALID',
   1.108 +            message: ''
   1.109 +          }
   1.110 +        }
   1.111 +      },
   1.112 +      exec: {
   1.113 +        output: 'Using tsn as a command prefix'
   1.114 +      }
   1.115 +    },
   1.116 +    // For comparison with earlier
   1.117 +    {
   1.118 +      setup:    'ext',
   1.119 +      check: {
   1.120 +        input:  'ext',
   1.121 +        hints:     ' <text>',
   1.122 +        markup: 'VVV',
   1.123 +        predictions: [ 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ],
   1.124 +        args: {
   1.125 +          command: { name: 'tsn ext' },
   1.126 +          text: {
   1.127 +            value: undefined,
   1.128 +            arg: '',
   1.129 +            status: 'INCOMPLETE'
   1.130 +          }
   1.131 +        }
   1.132 +      }
   1.133 +    },
   1.134 +    {
   1.135 +      setup:    'ext test',
   1.136 +      check: {
   1.137 +        input:  'ext test',
   1.138 +        hints:          '',
   1.139 +        markup: 'VVVVVVVV',
   1.140 +        args: {
   1.141 +          command: { name: 'tsn ext' },
   1.142 +          text: {
   1.143 +            value: 'test',
   1.144 +            arg: ' test',
   1.145 +            status: 'VALID',
   1.146 +            message: ''
   1.147 +          }
   1.148 +        }
   1.149 +      },
   1.150 +      exec: {
   1.151 +        output: 'Exec: tsnExt text=test'
   1.152 +      }
   1.153 +    },
   1.154 +    {
   1.155 +      setup:    'tsn',
   1.156 +      check: {
   1.157 +        input:  'tsn',
   1.158 +        hints:     ' deep down nested cmd',
   1.159 +        markup: 'III',
   1.160 +        message: '',
   1.161 +        predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ],
   1.162 +        args: {
   1.163 +          command: { name: 'tsn' },
   1.164 +        }
   1.165 +      }
   1.166 +    },
   1.167 +    // Does it actually work?
   1.168 +    {
   1.169 +      setup:    'tsb true',
   1.170 +      check: {
   1.171 +        input:  'tsb true',
   1.172 +        hints:          '',
   1.173 +        markup: 'VVVVVVVV',
   1.174 +        options: [ 'true' ],
   1.175 +        message: '',
   1.176 +        predictions: [ 'true' ],
   1.177 +        unassigned: [ ],
   1.178 +        args: {
   1.179 +          command: { name: 'tsb' },
   1.180 +          toggle: { value: true, arg: ' true', status: 'VALID', message: '' }
   1.181 +        }
   1.182 +      }
   1.183 +    },
   1.184 +    {
   1.185 +      // Bug 866710 - GCLI should allow argument merging for non-string parameters
   1.186 +      setup: 'context tsn ext',
   1.187 +      skip: true
   1.188 +    },
   1.189 +    {
   1.190 +      setup:    'context "tsn ext"',
   1.191 +      check: {
   1.192 +        input:  'context "tsn ext"',
   1.193 +        hints:                   '',
   1.194 +        markup: 'VVVVVVVVVVVVVVVVV',
   1.195 +        message: '',
   1.196 +        predictions: [ 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ],
   1.197 +        unassigned: [ ],
   1.198 +        args: {
   1.199 +          command: { name: 'context' },
   1.200 +          prefix: {
   1.201 +            value: options.requisition.canon.getCommand('tsn ext'),
   1.202 +            status: 'VALID',
   1.203 +            message: ''
   1.204 +          }
   1.205 +        }
   1.206 +      },
   1.207 +      exec: {
   1.208 +        output: 'Can\'t use \'tsn ext\' as a prefix because it is not a parent command.',
   1.209 +        error: true
   1.210 +      }
   1.211 +    },
   1.212 +    /*
   1.213 +    {
   1.214 +      setup:    'context "tsn deep"',
   1.215 +      check: {
   1.216 +        input:  'context "tsn deep"',
   1.217 +        hints:                    '',
   1.218 +        markup: 'VVVVVVVVVVVVVVVVVV',
   1.219 +        status: 'ERROR',
   1.220 +        message: '',
   1.221 +        predictions: [ 'tsn deep' ],
   1.222 +        unassigned: [ ],
   1.223 +        args: {
   1.224 +          command: { name: 'context' },
   1.225 +          prefix: {
   1.226 +            value: options.requisition.canon.getCommand('tsn deep'),
   1.227 +            status: 'VALID',
   1.228 +            message: ''
   1.229 +          }
   1.230 +        }
   1.231 +      },
   1.232 +      exec: {
   1.233 +        output: ''
   1.234 +      }
   1.235 +    },
   1.236 +    */
   1.237 +    {
   1.238 +      setup:    'context',
   1.239 +      check: {
   1.240 +        input:  'context',
   1.241 +        hints:         ' [prefix]',
   1.242 +        markup: 'VVVVVVV',
   1.243 +        status: 'VALID',
   1.244 +        unassigned: [ ],
   1.245 +        args: {
   1.246 +          command: { name: 'context' },
   1.247 +          prefix: { value: undefined, arg: '', status: 'VALID', message: '' },
   1.248 +        }
   1.249 +      },
   1.250 +      exec: {
   1.251 +        output: 'Command prefix is unset',
   1.252 +        type: 'string',
   1.253 +        error: false
   1.254 +      }
   1.255 +    }
   1.256 +  ]);
   1.257 +};

mercurial