browser/devtools/commandline/test/browser_gcli_remotews.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_remotews.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,500 @@
     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-testRemoteWs.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 +// testRemoteWs and testRemoteXhr are virtually identical.
    1.50 +// Changes made here should be made there too.
    1.51 +// They are kept separate to save adding complexity to the test system and so
    1.52 +// to help us select the test that are available in different environments
    1.53 +
    1.54 +exports.testRemoteWebsocket = function(options) {
    1.55 +  return helpers.audit(options, [
    1.56 +    {
    1.57 +      skipRemainingIf: options.isRemote || options.isNode || options.isFirefox,
    1.58 +      setup:    'remote ',
    1.59 +      check: {
    1.60 +        input:  'remote ',
    1.61 +        hints:         '',
    1.62 +        markup: 'EEEEEEV',
    1.63 +        cursor: 7,
    1.64 +        current: '__command',
    1.65 +        status: 'ERROR',
    1.66 +        options: [ ],
    1.67 +        message: 'Can\'t use \'remote\'.',
    1.68 +        predictions: [ ],
    1.69 +        unassigned: [ ],
    1.70 +      }
    1.71 +    },
    1.72 +    {
    1.73 +      setup: 'connect remote',
    1.74 +      check: {
    1.75 +        args: {
    1.76 +          prefix: { value: 'remote' },
    1.77 +          url: { value: undefined }
    1.78 +        }
    1.79 +      },
    1.80 +      exec: {
    1.81 +        error: false
    1.82 +      }
    1.83 +    },
    1.84 +    {
    1.85 +      setup: 'disconnect remote',
    1.86 +      check: {
    1.87 +        args: {
    1.88 +          prefix: {
    1.89 +            value: function(connection) {
    1.90 +              assert.is(connection.prefix, 'remote', 'disconnecting remote');
    1.91 +            }
    1.92 +          }
    1.93 +        }
    1.94 +      },
    1.95 +      exec: {
    1.96 +        output: /^Removed [0-9]* commands.$/,
    1.97 +        type: 'string',
    1.98 +        error: false
    1.99 +      }
   1.100 +    },
   1.101 +    {
   1.102 +      setup: 'connect remote --method websocket',
   1.103 +      check: {
   1.104 +        args: {
   1.105 +          prefix: { value: 'remote' },
   1.106 +          url: { value: undefined }
   1.107 +        }
   1.108 +      },
   1.109 +      exec: {
   1.110 +        error: false
   1.111 +      }
   1.112 +    },
   1.113 +    {
   1.114 +      setup: 'disconnect remote',
   1.115 +      check: {
   1.116 +        args: {
   1.117 +          prefix: {
   1.118 +            value: function(connection) {
   1.119 +              assert.is(connection.prefix, 'remote', 'disconnecting remote');
   1.120 +            }
   1.121 +          }
   1.122 +        }
   1.123 +      },
   1.124 +      exec: {
   1.125 +        output: /^Removed [0-9]* commands.$/,
   1.126 +        type: 'string',
   1.127 +        error: false
   1.128 +      }
   1.129 +    },
   1.130 +    {
   1.131 +      setup: 'connect remote --method websocket',
   1.132 +      check: {
   1.133 +        args: {
   1.134 +          prefix: { value: 'remote' },
   1.135 +          url: { value: undefined }
   1.136 +        }
   1.137 +      },
   1.138 +      exec: {
   1.139 +        output: /^Added [0-9]* commands.$/,
   1.140 +        type: 'string',
   1.141 +        error: false
   1.142 +      }
   1.143 +    },
   1.144 +    {
   1.145 +      setup:    'remote ',
   1.146 +      check: {
   1.147 +        input:  'remote ',
   1.148 +        // PhantomJS fails on this. Unsure why
   1.149 +        // hints:         ' {',
   1.150 +        markup: 'IIIIIIV',
   1.151 +        status: 'ERROR',
   1.152 +        optionsIncludes: [
   1.153 +          'remote', 'remote cd', 'remote context', 'remote echo',
   1.154 +          'remote exec', 'remote exit', 'remote firefox', 'remote help',
   1.155 +          'remote intro', 'remote make'
   1.156 +        ],
   1.157 +        message: '',
   1.158 +        predictionsIncludes: [ 'remote' ],
   1.159 +        unassigned: [ ],
   1.160 +      }
   1.161 +    },
   1.162 +    {
   1.163 +      setup:    'remote echo hello world',
   1.164 +      check: {
   1.165 +        input:  'remote echo hello world',
   1.166 +        hints:                         '',
   1.167 +        markup: 'VVVVVVVVVVVVVVVVVVVVVVV',
   1.168 +        cursor: 23,
   1.169 +        current: 'message',
   1.170 +        status: 'VALID',
   1.171 +        options: [ ],
   1.172 +        message: '',
   1.173 +        predictions: [ ],
   1.174 +        unassigned: [ ],
   1.175 +        args: {
   1.176 +          command: { name: 'remote echo' },
   1.177 +          message: {
   1.178 +            value: 'hello world',
   1.179 +            arg: ' hello world',
   1.180 +            status: 'VALID',
   1.181 +            message: ''
   1.182 +          }
   1.183 +        }
   1.184 +      },
   1.185 +      exec: {
   1.186 +        output: 'hello world',
   1.187 +        type: 'string',
   1.188 +        error: false
   1.189 +      }
   1.190 +    },
   1.191 +    {
   1.192 +      setup:    'remote exec ls',
   1.193 +      check: {
   1.194 +        input:  'remote exec ls',
   1.195 +        hints:                '',
   1.196 +        markup: 'VVVVVVVVVVVVVV',
   1.197 +        cursor: 14,
   1.198 +        current: 'command',
   1.199 +        status: 'VALID',
   1.200 +        options: [ ],
   1.201 +        message: '',
   1.202 +        predictions: [ ],
   1.203 +        unassigned: [ ],
   1.204 +        args: {
   1.205 +          command: {
   1.206 +            value: 'ls',
   1.207 +            arg: ' ls',
   1.208 +            status: 'VALID',
   1.209 +            message: ''
   1.210 +          }
   1.211 +        }
   1.212 +      },
   1.213 +      exec: {
   1.214 +        // output: '', We can't rely on the contents of the FS
   1.215 +        type: 'output',
   1.216 +        error: false
   1.217 +      }
   1.218 +    },
   1.219 +    {
   1.220 +      setup:    'remote sleep mistake',
   1.221 +      check: {
   1.222 +        input:  'remote sleep mistake',
   1.223 +        hints:                      '',
   1.224 +        markup: 'VVVVVVVVVVVVVEEEEEEE',
   1.225 +        cursor: 20,
   1.226 +        current: 'length',
   1.227 +        status: 'ERROR',
   1.228 +        options: [ ],
   1.229 +        message: 'Can\'t convert "mistake" to a number.',
   1.230 +        predictions: [ ],
   1.231 +        unassigned: [ ],
   1.232 +        args: {
   1.233 +          command: { name: 'remote sleep' },
   1.234 +          length: {
   1.235 +            value: undefined,
   1.236 +            arg: ' mistake',
   1.237 +            status: 'ERROR',
   1.238 +            message: 'Can\'t convert "mistake" to a number.'
   1.239 +          }
   1.240 +        }
   1.241 +      }
   1.242 +    },
   1.243 +    {
   1.244 +      setup:    'remote sleep 1',
   1.245 +      check: {
   1.246 +        input:  'remote sleep 1',
   1.247 +        hints:                 '',
   1.248 +        markup: 'VVVVVVVVVVVVVV',
   1.249 +        cursor: 14,
   1.250 +        current: 'length',
   1.251 +        status: 'VALID',
   1.252 +        options: [ ],
   1.253 +        message: '',
   1.254 +        predictions: [ ],
   1.255 +        unassigned: [ ],
   1.256 +        args: {
   1.257 +          command: { name: 'remote sleep' },
   1.258 +          length: { value: 1, arg: ' 1', status: 'VALID', message: '' }
   1.259 +        }
   1.260 +      },
   1.261 +      exec: {
   1.262 +        output: 'Done',
   1.263 +        type: 'string',
   1.264 +        error: false
   1.265 +      }
   1.266 +    },
   1.267 +    {
   1.268 +      setup:    'remote help ',
   1.269 +      skipIf: true, // The help command is not remotable
   1.270 +      check: {
   1.271 +        input:  'remote help ',
   1.272 +        hints:              '[search]',
   1.273 +        markup: 'VVVVVVVVVVVV',
   1.274 +        cursor: 12,
   1.275 +        current: 'search',
   1.276 +        status: 'VALID',
   1.277 +        options: [ ],
   1.278 +        message: '',
   1.279 +        predictions: [ ],
   1.280 +        unassigned: [ ],
   1.281 +        args: {
   1.282 +          command: { name: 'remote help' },
   1.283 +          search: {
   1.284 +            value: undefined,
   1.285 +            arg: '',
   1.286 +            status: 'VALID',
   1.287 +            message: ''
   1.288 +          }
   1.289 +        }
   1.290 +      },
   1.291 +      exec: {
   1.292 +        output: '',
   1.293 +        type: 'string',
   1.294 +        error: false
   1.295 +      }
   1.296 +    },
   1.297 +    {
   1.298 +      setup:    'remote intro',
   1.299 +      check: {
   1.300 +        input:  'remote intro',
   1.301 +        hints:              '',
   1.302 +        markup: 'VVVVVVVVVVVV',
   1.303 +        cursor: 12,
   1.304 +        current: '__command',
   1.305 +        status: 'VALID',
   1.306 +        options: [ ],
   1.307 +        message: '',
   1.308 +        predictions: [ ],
   1.309 +        unassigned: [ ],
   1.310 +        args: {
   1.311 +          command: { name: 'remote intro' }
   1.312 +        }
   1.313 +      },
   1.314 +      exec: {
   1.315 +        output: [
   1.316 +          /^GCLI is an experiment/,
   1.317 +          /F1\/Escape/
   1.318 +        ],
   1.319 +        type: 'intro',
   1.320 +        error: false
   1.321 +      }
   1.322 +    },
   1.323 +    {
   1.324 +      setup:    'context remote',
   1.325 +      check: {
   1.326 +        input:  'context remote',
   1.327 +        // hints:                ' {',
   1.328 +        markup: 'VVVVVVVVVVVVVV',
   1.329 +        cursor: 14,
   1.330 +        current: 'prefix',
   1.331 +        status: 'VALID',
   1.332 +        optionsContains: [
   1.333 +          'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit',
   1.334 +          'remote firefox', 'remote help', 'remote intro', 'remote make'
   1.335 +        ],
   1.336 +        message: '',
   1.337 +        // predictionsContains: [
   1.338 +        //   'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit',
   1.339 +        //   'remote firefox', 'remote help', 'remote intro', 'remote make',
   1.340 +        //   'remote pref'
   1.341 +        // ],
   1.342 +        unassigned: [ ],
   1.343 +        args: {
   1.344 +          command: { name: 'context' },
   1.345 +          prefix: {
   1.346 +            arg: ' remote',
   1.347 +            status: 'VALID',
   1.348 +            message: ''
   1.349 +          }
   1.350 +        }
   1.351 +      },
   1.352 +      exec: {
   1.353 +        output: 'Using remote as a command prefix',
   1.354 +        type: 'string',
   1.355 +        error: false
   1.356 +      }
   1.357 +    },
   1.358 +    {
   1.359 +      setup:    'exec ls',
   1.360 +      check: {
   1.361 +        input:  'exec ls',
   1.362 +        hints:         '',
   1.363 +        markup: 'VVVVVVV',
   1.364 +        cursor: 7,
   1.365 +        current: 'command',
   1.366 +        status: 'VALID',
   1.367 +        options: [ ],
   1.368 +        message: '',
   1.369 +        predictions: [ ],
   1.370 +        unassigned: [ ],
   1.371 +        args: {
   1.372 +          command: { value: 'ls', arg: ' ls', status: 'VALID', message: '' },
   1.373 +        }
   1.374 +      },
   1.375 +      exec: {
   1.376 +        // output: '', We can't rely on the contents of the filesystem
   1.377 +        type: 'output',
   1.378 +        error: false
   1.379 +      }
   1.380 +    },
   1.381 +    {
   1.382 +      setup:    'echo hello world',
   1.383 +      check: {
   1.384 +        input:  'echo hello world',
   1.385 +        hints:                  '',
   1.386 +        markup: 'VVVVVVVVVVVVVVVV',
   1.387 +        cursor: 16,
   1.388 +        current: 'message',
   1.389 +        status: 'VALID',
   1.390 +        options: [ ],
   1.391 +        message: '',
   1.392 +        predictions: [ ],
   1.393 +        unassigned: [ ],
   1.394 +        args: {
   1.395 +          command: { name: 'remote echo' },
   1.396 +          message: {
   1.397 +            value: 'hello world',
   1.398 +            arg: ' hello world',
   1.399 +            status: 'VALID',
   1.400 +            message: ''
   1.401 +          }
   1.402 +        }
   1.403 +      },
   1.404 +      exec: {
   1.405 +        output: /^hello world$/,
   1.406 +        type: 'string',
   1.407 +        error: false
   1.408 +      }
   1.409 +    },
   1.410 +    {
   1.411 +      setup:    'context',
   1.412 +      check: {
   1.413 +        input:  'context',
   1.414 +        hints:         ' [prefix]',
   1.415 +        markup: 'VVVVVVV',
   1.416 +        cursor: 7,
   1.417 +        current: '__command',
   1.418 +        status: 'VALID',
   1.419 +        optionsContains: [
   1.420 +          'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit',
   1.421 +          'remote firefox', 'remote help', 'remote intro', 'remote make'
   1.422 +        ],
   1.423 +        message: '',
   1.424 +        predictions: [ ],
   1.425 +        unassigned: [ ],
   1.426 +        args: {
   1.427 +          command: { name: 'context' },
   1.428 +          prefix: { value: undefined, arg: '', status: 'VALID', message: '' }
   1.429 +        }
   1.430 +      },
   1.431 +      exec: {
   1.432 +        output: 'Command prefix is unset',
   1.433 +        type: 'string',
   1.434 +        error: false
   1.435 +      }
   1.436 +    },
   1.437 +    {
   1.438 +      setup:    'disconnect ',
   1.439 +      check: {
   1.440 +        input:  'disconnect ',
   1.441 +        hints:             'remote',
   1.442 +        markup: 'VVVVVVVVVVV',
   1.443 +        cursor: 11,
   1.444 +        current: 'prefix',
   1.445 +        status: 'ERROR',
   1.446 +        options: [ 'remote' ],
   1.447 +        message: '',
   1.448 +        predictions: [ 'remote' ],
   1.449 +        unassigned: [ ],
   1.450 +        args: {
   1.451 +          command: { name: 'disconnect' },
   1.452 +          prefix: {
   1.453 +            value: undefined,
   1.454 +            arg: '',
   1.455 +            status: 'INCOMPLETE',
   1.456 +            message: 'Value required for \'prefix\'.'
   1.457 +          }
   1.458 +        }
   1.459 +      }
   1.460 +    },
   1.461 +    {
   1.462 +      setup:    'disconnect remote',
   1.463 +      check: {
   1.464 +        input:  'disconnect remote',
   1.465 +        hints:                   '',
   1.466 +        markup: 'VVVVVVVVVVVVVVVVV',
   1.467 +        status: 'VALID',
   1.468 +        message: '',
   1.469 +        unassigned: [ ],
   1.470 +        args: {
   1.471 +          prefix: {
   1.472 +            value: function(connection) {
   1.473 +              assert.is(connection.prefix, 'remote', 'disconnecting remote');
   1.474 +            },
   1.475 +            arg: ' remote',
   1.476 +            status: 'VALID',
   1.477 +            message: ''
   1.478 +          }
   1.479 +        }
   1.480 +      },
   1.481 +      exec: {
   1.482 +        output: /^Removed [0-9]* commands.$/,
   1.483 +        type: 'string',
   1.484 +        error: false
   1.485 +      }
   1.486 +    },
   1.487 +    {
   1.488 +      setup:    'remote ',
   1.489 +      check: {
   1.490 +        input:  'remote ',
   1.491 +        hints:         '',
   1.492 +        markup: 'EEEEEEV',
   1.493 +        cursor: 7,
   1.494 +        current: '__command',
   1.495 +        status: 'ERROR',
   1.496 +        options: [ ],
   1.497 +        message: 'Can\'t use \'remote\'.',
   1.498 +        predictions: [ ],
   1.499 +        unassigned: [ ],
   1.500 +      }
   1.501 +    }
   1.502 +  ]);
   1.503 +};

mercurial