browser/devtools/commandline/test/browser_gcli_node.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.

     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-testNode.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 assert = require('../testharness/assert');
    44 // var helpers = require('./helpers');
    45 var nodetype = require('gcli/types/node');
    47 exports.setup = function(options) {
    48   if (options.window) {
    49     nodetype.setDocument(options.window.document);
    50   }
    51 };
    53 exports.shutdown = function(options) {
    54   nodetype.unsetDocument();
    55 };
    57 exports.testNode = function(options) {
    58   return helpers.audit(options, [
    59     {
    60       setup:    'tse ',
    61       check: {
    62         input:  'tse ',
    63         hints:      '<node> [options]',
    64         markup: 'VVVV',
    65         cursor: 4,
    66         current: 'node',
    67         status: 'ERROR',
    68         args: {
    69           command: { name: 'tse' },
    70           node: { status: 'INCOMPLETE' },
    71           nodes: { status: 'VALID' },
    72           nodes2: { status: 'VALID' }
    73         }
    74       }
    75     },
    76     {
    77       setup:    'tse :',
    78       check: {
    79         input:  'tse :',
    80         hints:       ' [options]',
    81         markup: 'VVVVE',
    82         cursor: 5,
    83         current: 'node',
    84         status: 'ERROR',
    85         args: {
    86           command: { name: 'tse' },
    87           node: {
    88             arg: ' :',
    89             status: 'ERROR',
    90             message: 'Syntax error in CSS query'
    91           },
    92           nodes: { status: 'VALID' },
    93           nodes2: { status: 'VALID' }
    94         }
    95       }
    96     },
    97     {
    98       setup:    'tse #',
    99       check: {
   100         input:  'tse #',
   101         hints:       ' [options]',
   102         markup: 'VVVVE',
   103         cursor: 5,
   104         current: 'node',
   105         status: 'ERROR',
   106         args: {
   107           command: { name: 'tse' },
   108           node: {
   109             value: undefined,
   110             arg: ' #',
   111             status: 'ERROR',
   112             message: 'Syntax error in CSS query'
   113           },
   114           nodes: { status: 'VALID' },
   115           nodes2: { status: 'VALID' }
   116         }
   117       }
   118     },
   119     {
   120       setup:    'tse .',
   121       check: {
   122         input:  'tse .',
   123         hints:       ' [options]',
   124         markup: 'VVVVE',
   125         cursor: 5,
   126         current: 'node',
   127         status: 'ERROR',
   128         args: {
   129           command: { name: 'tse' },
   130           node: {
   131             value: undefined,
   132             arg: ' .',
   133             status: 'ERROR',
   134             message: 'Syntax error in CSS query'
   135           },
   136           nodes: { status: 'VALID' },
   137           nodes2: { status: 'VALID' }
   138         }
   139       }
   140     },
   141     {
   142       setup:    'tse *',
   143       check: {
   144         input:  'tse *',
   145         hints:       ' [options]',
   146         markup: 'VVVVE',
   147         cursor: 5,
   148         current: 'node',
   149         status: 'ERROR',
   150         args: {
   151           command: { name: 'tse' },
   152           node: {
   153             value: undefined,
   154             arg: ' *',
   155             status: 'ERROR'
   156             // message: 'Too many matches (128)'
   157           },
   158           nodes: { status: 'VALID' },
   159           nodes2: { status: 'VALID' }
   160         }
   161       }
   162     }
   163   ]);
   164 };
   166 exports.testNodeDom = function(options) {
   167   var requisition = options.requisition;
   169   return helpers.audit(options, [
   170     {
   171       skipRemainingIf: options.isNoDom,
   172       setup:    'tse :root',
   173       check: {
   174         input:  'tse :root',
   175         hints:           ' [options]',
   176         markup: 'VVVVVVVVV',
   177         cursor: 9,
   178         current: 'node',
   179         status: 'VALID',
   180         args: {
   181           command: { name: 'tse' },
   182           node: { arg: ' :root', status: 'VALID' },
   183           nodes: { status: 'VALID' },
   184           nodes2: { status: 'VALID' }
   185         }
   186       }
   187     },
   188     {
   189       setup:    'tse :root ',
   190       check: {
   191         input:  'tse :root ',
   192         hints:            '[options]',
   193         markup: 'VVVVVVVVVV',
   194         cursor: 10,
   195         current: 'node',
   196         status: 'VALID',
   197         args: {
   198           command: { name: 'tse' },
   199           node: { arg: ' :root ', status: 'VALID' },
   200           nodes: { status: 'VALID' },
   201           nodes2: { status: 'VALID' }
   202         }
   203       },
   204       post: function() {
   205         assert.is(requisition.getAssignment('node').value.tagName,
   206                   'HTML',
   207                   'root id');
   208       }
   209     },
   210     {
   211       setup:    'tse #gcli-nomatch',
   212       check: {
   213         input:  'tse #gcli-nomatch',
   214         hints:                   ' [options]',
   215         markup: 'VVVVIIIIIIIIIIIII',
   216         cursor: 17,
   217         current: 'node',
   218         status: 'ERROR',
   219         args: {
   220           command: { name: 'tse' },
   221           node: {
   222             value: undefined,
   223             arg: ' #gcli-nomatch',
   224             status: 'INCOMPLETE',
   225             message: 'No matches'
   226           },
   227           nodes: { status: 'VALID' },
   228           nodes2: { status: 'VALID' }
   229         }
   230       }
   231     }
   232   ]);
   233 };
   235 exports.testNodes = function(options) {
   236   var requisition = options.requisition;
   238   return helpers.audit(options, [
   239     {
   240       skipRemainingIf: options.isNoDom,
   241       setup:    'tse :root --nodes *',
   242       check: {
   243         input:  'tse :root --nodes *',
   244         hints:                       ' [options]',
   245         markup: 'VVVVVVVVVVVVVVVVVVV',
   246         current: 'nodes',
   247         status: 'VALID',
   248         args: {
   249           command: { name: 'tse' },
   250           node: { arg: ' :root', status: 'VALID' },
   251           nodes: { arg: ' --nodes *', status: 'VALID' },
   252           nodes2: { status: 'VALID' }
   253         }
   254       },
   255       post: function() {
   256         assert.is(requisition.getAssignment('node').value.tagName,
   257                   'HTML',
   258                   '#gcli-input id');
   259       }
   260     },
   261     {
   262       setup:    'tse :root --nodes2 div',
   263       check: {
   264         input:  'tse :root --nodes2 div',
   265         hints:                       ' [options]',
   266         markup: 'VVVVVVVVVVVVVVVVVVVVVV',
   267         cursor: 22,
   268         current: 'nodes2',
   269         status: 'VALID',
   270         args: {
   271           command: { name: 'tse' },
   272           node: { arg: ' :root', status: 'VALID' },
   273           nodes: { status: 'VALID' },
   274           nodes2: { arg: ' --nodes2 div', status: 'VALID' }
   275         }
   276       },
   277       post: function() {
   278         assert.is(requisition.getAssignment('node').value.tagName,
   279                   'HTML',
   280                   'root id');
   281       }
   282     },
   283     {
   284       setup:    'tse --nodes ffff',
   285       check: {
   286         input:  'tse --nodes ffff',
   287         hints:                  ' <node> [options]',
   288         markup: 'VVVVIIIIIIIVIIII',
   289         cursor: 16,
   290         current: 'nodes',
   291         status: 'ERROR',
   292         args: {
   293           command: { name: 'tse' },
   294           node: {
   295             value: undefined,
   296             arg: '',
   297             status: 'INCOMPLETE'
   298           },
   299           nodes: {
   300             value: undefined,
   301             arg: ' --nodes ffff',
   302             status: 'INCOMPLETE',
   303             message: 'No matches'
   304           },
   305           nodes2: { arg: '', status: 'VALID', message: '' }
   306         }
   307       },
   308       post: function() {
   309         /*
   310         assert.is(requisition.getAssignment('nodes2').value.constructor.name,
   311                   'NodeList',
   312                   '#gcli-input id');
   313         */
   314       }
   315     },
   316     {
   317       setup:    'tse --nodes2 ffff',
   318       check: {
   319         input:  'tse --nodes2 ffff',
   320         hints:                   ' <node> [options]',
   321         markup: 'VVVVVVVVVVVVVVVVV',
   322         cursor: 17,
   323         current: 'nodes2',
   324         status: 'ERROR',
   325         args: {
   326           command: { name: 'tse' },
   327           node: {
   328             value: undefined,
   329             arg: '',
   330             status: 'INCOMPLETE'
   331           },
   332           nodes: { arg: '', status: 'VALID', message: '' },
   333           nodes2: { arg: ' --nodes2 ffff', status: 'VALID', message: '' }
   334         }
   335       },
   336       post: function() {
   337         /*
   338         assert.is(requisition.getAssignment('nodes').value.constructor.name,
   339                   'NodeList',
   340                   '#gcli-input id');
   341         assert.is(requisition.getAssignment('nodes2').value.constructor.name,
   342                   'NodeList',
   343                   '#gcli-input id');
   344         */
   345       }
   346     },
   347   ]);
   348 };

mercurial