browser/devtools/commandline/test/browser_gcli_string.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 /*
     2  * Copyright 2012, Mozilla Foundation and contributors
     3  *
     4  * Licensed under the Apache License, Version 2.0 (the "License");
     5  * you may not use this file except in compliance with the License.
     6  * You may obtain a copy of the License at
     7  *
     8  * http://www.apache.org/licenses/LICENSE-2.0
     9  *
    10  * Unless required by applicable law or agreed to in writing, software
    11  * distributed under the License is distributed on an "AS IS" BASIS,
    12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  * See the License for the specific language governing permissions and
    14  * limitations under the License.
    15  */
    17 'use strict';
    18 // <INJECTED SOURCE:START>
    20 // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
    21 // DO NOT EDIT IT DIRECTLY
    23 var exports = {};
    25 var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testString.js</p>";
    27 function test() {
    28   return Task.spawn(function() {
    29     let options = yield helpers.openTab(TEST_URI);
    30     yield helpers.openToolbar(options);
    31     gcli.addItems(mockCommands.items);
    33     yield helpers.runTests(options, exports);
    35     gcli.removeItems(mockCommands.items);
    36     yield helpers.closeToolbar(options);
    37     yield helpers.closeTab(options);
    38   }).then(finish, helpers.handleError);
    39 }
    41 // <INJECTED SOURCE:END>
    43 // var helpers = require('./helpers');
    45 exports.testNewLine = function(options) {
    46   return helpers.audit(options, [
    47     {
    48       setup:    'echo a\\nb',
    49       check: {
    50         input:  'echo a\\nb',
    51         hints:            '',
    52         markup: 'VVVVVVVVV',
    53         cursor: 9,
    54         current: 'message',
    55         status: 'VALID',
    56         args: {
    57           command: { name: 'echo' },
    58           message: {
    59             value: 'a\nb',
    60             arg: ' a\\nb',
    61             status: 'VALID',
    62             message: ''
    63           }
    64         }
    65       }
    66     }
    67   ]);
    68 };
    70 exports.testTab = function(options) {
    71   return helpers.audit(options, [
    72     {
    73       setup:    'echo a\\tb',
    74       check: {
    75         input:  'echo a\\tb',
    76         hints:            '',
    77         markup: 'VVVVVVVVV',
    78         cursor: 9,
    79         current: 'message',
    80         status: 'VALID',
    81         args: {
    82           command: { name: 'echo' },
    83           message: {
    84             value: 'a\tb',
    85             arg: ' a\\tb',
    86             status: 'VALID',
    87             message: ''
    88           }
    89         }
    90       }
    91     }
    92   ]);
    93 };
    95 exports.testEscape = function(options) {
    96   return helpers.audit(options, [
    97     {
    98       // What's typed is actually:
    99       //         tsrsrsr a\\ b c
   100       setup:    'tsrsrsr a\\\\ b c',
   101       check: {
   102         input:  'tsrsrsr a\\\\ b c',
   103         hints:                 '',
   104         markup: 'VVVVVVVVVVVVVVV',
   105         status: 'VALID',
   106         message: '',
   107         args: {
   108           command: { name: 'tsrsrsr' },
   109           p1: { value: 'a\\', arg: ' a\\\\', status: 'VALID', message: '' },
   110           p2: { value: 'b', arg: ' b', status: 'VALID', message: '' },
   111           p3: { value: 'c', arg: ' c', status: 'VALID', message: '' },
   112         }
   113       }
   114     },
   115     {
   116       // What's typed is actually:
   117       //         tsrsrsr abc\\ndef asd asd
   118       setup:    'tsrsrsr abc\\\\ndef asd asd',
   119       check: {
   120         input:  'tsrsrsr abc\\\\ndef asd asd',
   121         hints:                           '',
   122         markup: 'VVVVVVVVVVVVVVVVVVVVVVVVV',
   123         status: 'VALID',
   124         message: '',
   125         args: {
   126           command: { name: 'tsrsrsr' },
   127           p1: {
   128             value: 'abc\\ndef',
   129             arg: ' abc\\\\ndef',
   130             status: 'VALID',
   131             message: ''
   132           },
   133           p2: { value: 'asd', arg: ' asd', status: 'VALID', message: '' },
   134           p3: { value: 'asd', arg: ' asd', status: 'VALID', message: '' },
   135         }
   136       }
   137     }
   138   ]);
   139 };
   141 exports.testBlank = function(options) {
   142   return helpers.audit(options, [
   143     {
   144       setup:    'tsrsrsr a "" c',
   145       check: {
   146         input:  'tsrsrsr a "" c',
   147         hints:                '',
   148         markup: 'VVVVVVVVVVVVVV',
   149         cursor: 14,
   150         current: 'p3',
   151         status: 'ERROR',
   152         message: '',
   153         args: {
   154           command: { name: 'tsrsrsr' },
   155           p1: {
   156             value: 'a',
   157             arg: ' a',
   158             status: 'VALID',
   159             message: ''
   160           },
   161           p2: {
   162             value: undefined,
   163             arg: ' ""',
   164             status: 'INCOMPLETE'
   165           },
   166           p3: {
   167             value: 'c',
   168             arg: ' c',
   169             status: 'VALID',
   170             message: ''
   171           }
   172         }
   173       }
   174     },
   175     {
   176       setup:    'tsrsrsr a b ""',
   177       check: {
   178         input:  'tsrsrsr a b ""',
   179         hints:                '',
   180         markup: 'VVVVVVVVVVVVVV',
   181         cursor: 14,
   182         current: 'p3',
   183         status: 'VALID',
   184         message: '',
   185         args: {
   186           command: { name: 'tsrsrsr' },
   187           p1: {
   188             value: 'a',
   189             arg: ' a',
   190             status:'VALID',
   191             message: '' },
   192           p2: {
   193             value: 'b',
   194             arg: ' b',
   195             status: 'VALID',
   196             message: ''
   197           },
   198           p3: {
   199             value: '',
   200             arg: ' ""',
   201             status: 'VALID',
   202             message: ''
   203           }
   204         }
   205       }
   206     }
   207   ]);
   208 };
   210 exports.testBlankWithParam = function(options) {
   211   return helpers.audit(options, [
   212     {
   213       setup:    'tsrsrsr  a --p3',
   214       check: {
   215         input:  'tsrsrsr  a --p3',
   216         hints:                 ' <string> <p2>',
   217         markup: 'VVVVVVVVVVVVVVV',
   218         cursor: 15,
   219         current: 'p3',
   220         status: 'ERROR',
   221         message: '',
   222         args: {
   223           command: { name: 'tsrsrsr' },
   224           p1: { value: 'a', arg: '  a', status: 'VALID', message: '' },
   225           p2: { value: undefined, arg: '', status: 'INCOMPLETE' },
   226           p3: { value: '', arg: ' --p3', status: 'VALID', message: '' },
   227         }
   228       }
   229     },
   230     {
   231       setup:    'tsrsrsr  a --p3 ',
   232       check: {
   233         input:  'tsrsrsr  a --p3 ',
   234         hints:                  '<string> <p2>',
   235         markup: 'VVVVVVVVVVVVVVVV',
   236         cursor: 16,
   237         current: 'p3',
   238         status: 'ERROR',
   239         message: '',
   240         args: {
   241           command: { name: 'tsrsrsr' },
   242           p1: { value: 'a', arg: '  a', status: 'VALID', message: '' },
   243           p2: { value: undefined, arg: '', status: 'INCOMPLETE' },
   244           p3: { value: '', arg: ' --p3 ', status: 'VALID', message: '' },
   245         }
   246       }
   247     },
   248     {
   249       setup:    'tsrsrsr  a --p3 "',
   250       check: {
   251         input:  'tsrsrsr  a --p3 "',
   252         hints:                   ' <p2>',
   253         markup: 'VVVVVVVVVVVVVVVVV',
   254         cursor: 17,
   255         current: 'p3',
   256         status: 'ERROR',
   257         message: '',
   258         args: {
   259           command: { name: 'tsrsrsr' },
   260           p1: { value: 'a', arg: '  a', status: 'VALID', message: '' },
   261           p2: { value: undefined, arg: '', status: 'INCOMPLETE' },
   262           p3: { value: '', arg: ' --p3 "', status: 'VALID', message: '' },
   263         }
   264       }
   265     },
   266     {
   267       setup:    'tsrsrsr  a --p3 ""',
   268       check: {
   269         input:  'tsrsrsr  a --p3 ""',
   270         hints:                    ' <p2>',
   271         markup: 'VVVVVVVVVVVVVVVVVV',
   272         cursor: 18,
   273         current: 'p3',
   274         status: 'ERROR',
   275         message: '',
   276         args: {
   277           command: { name: 'tsrsrsr' },
   278           p1: { value: 'a', arg: '  a', status: 'VALID', message: '' },
   279           p2: { value: undefined, arg: '', status: 'INCOMPLETE' },
   280           p3: { value: '', arg: ' --p3 ""', status: 'VALID', message: '' },
   281         }
   282       }
   283     }
   284   ]);
   285 };

mercurial