1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/commandline/test/browser_gcli_node.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,348 @@ 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-testNode.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 +var nodetype = require('gcli/types/node'); 1.49 + 1.50 +exports.setup = function(options) { 1.51 + if (options.window) { 1.52 + nodetype.setDocument(options.window.document); 1.53 + } 1.54 +}; 1.55 + 1.56 +exports.shutdown = function(options) { 1.57 + nodetype.unsetDocument(); 1.58 +}; 1.59 + 1.60 +exports.testNode = function(options) { 1.61 + return helpers.audit(options, [ 1.62 + { 1.63 + setup: 'tse ', 1.64 + check: { 1.65 + input: 'tse ', 1.66 + hints: '<node> [options]', 1.67 + markup: 'VVVV', 1.68 + cursor: 4, 1.69 + current: 'node', 1.70 + status: 'ERROR', 1.71 + args: { 1.72 + command: { name: 'tse' }, 1.73 + node: { status: 'INCOMPLETE' }, 1.74 + nodes: { status: 'VALID' }, 1.75 + nodes2: { status: 'VALID' } 1.76 + } 1.77 + } 1.78 + }, 1.79 + { 1.80 + setup: 'tse :', 1.81 + check: { 1.82 + input: 'tse :', 1.83 + hints: ' [options]', 1.84 + markup: 'VVVVE', 1.85 + cursor: 5, 1.86 + current: 'node', 1.87 + status: 'ERROR', 1.88 + args: { 1.89 + command: { name: 'tse' }, 1.90 + node: { 1.91 + arg: ' :', 1.92 + status: 'ERROR', 1.93 + message: 'Syntax error in CSS query' 1.94 + }, 1.95 + nodes: { status: 'VALID' }, 1.96 + nodes2: { status: 'VALID' } 1.97 + } 1.98 + } 1.99 + }, 1.100 + { 1.101 + setup: 'tse #', 1.102 + check: { 1.103 + input: 'tse #', 1.104 + hints: ' [options]', 1.105 + markup: 'VVVVE', 1.106 + cursor: 5, 1.107 + current: 'node', 1.108 + status: 'ERROR', 1.109 + args: { 1.110 + command: { name: 'tse' }, 1.111 + node: { 1.112 + value: undefined, 1.113 + arg: ' #', 1.114 + status: 'ERROR', 1.115 + message: 'Syntax error in CSS query' 1.116 + }, 1.117 + nodes: { status: 'VALID' }, 1.118 + nodes2: { status: 'VALID' } 1.119 + } 1.120 + } 1.121 + }, 1.122 + { 1.123 + setup: 'tse .', 1.124 + check: { 1.125 + input: 'tse .', 1.126 + hints: ' [options]', 1.127 + markup: 'VVVVE', 1.128 + cursor: 5, 1.129 + current: 'node', 1.130 + status: 'ERROR', 1.131 + args: { 1.132 + command: { name: 'tse' }, 1.133 + node: { 1.134 + value: undefined, 1.135 + arg: ' .', 1.136 + status: 'ERROR', 1.137 + message: 'Syntax error in CSS query' 1.138 + }, 1.139 + nodes: { status: 'VALID' }, 1.140 + nodes2: { status: 'VALID' } 1.141 + } 1.142 + } 1.143 + }, 1.144 + { 1.145 + setup: 'tse *', 1.146 + check: { 1.147 + input: 'tse *', 1.148 + hints: ' [options]', 1.149 + markup: 'VVVVE', 1.150 + cursor: 5, 1.151 + current: 'node', 1.152 + status: 'ERROR', 1.153 + args: { 1.154 + command: { name: 'tse' }, 1.155 + node: { 1.156 + value: undefined, 1.157 + arg: ' *', 1.158 + status: 'ERROR' 1.159 + // message: 'Too many matches (128)' 1.160 + }, 1.161 + nodes: { status: 'VALID' }, 1.162 + nodes2: { status: 'VALID' } 1.163 + } 1.164 + } 1.165 + } 1.166 + ]); 1.167 +}; 1.168 + 1.169 +exports.testNodeDom = function(options) { 1.170 + var requisition = options.requisition; 1.171 + 1.172 + return helpers.audit(options, [ 1.173 + { 1.174 + skipRemainingIf: options.isNoDom, 1.175 + setup: 'tse :root', 1.176 + check: { 1.177 + input: 'tse :root', 1.178 + hints: ' [options]', 1.179 + markup: 'VVVVVVVVV', 1.180 + cursor: 9, 1.181 + current: 'node', 1.182 + status: 'VALID', 1.183 + args: { 1.184 + command: { name: 'tse' }, 1.185 + node: { arg: ' :root', status: 'VALID' }, 1.186 + nodes: { status: 'VALID' }, 1.187 + nodes2: { status: 'VALID' } 1.188 + } 1.189 + } 1.190 + }, 1.191 + { 1.192 + setup: 'tse :root ', 1.193 + check: { 1.194 + input: 'tse :root ', 1.195 + hints: '[options]', 1.196 + markup: 'VVVVVVVVVV', 1.197 + cursor: 10, 1.198 + current: 'node', 1.199 + status: 'VALID', 1.200 + args: { 1.201 + command: { name: 'tse' }, 1.202 + node: { arg: ' :root ', status: 'VALID' }, 1.203 + nodes: { status: 'VALID' }, 1.204 + nodes2: { status: 'VALID' } 1.205 + } 1.206 + }, 1.207 + post: function() { 1.208 + assert.is(requisition.getAssignment('node').value.tagName, 1.209 + 'HTML', 1.210 + 'root id'); 1.211 + } 1.212 + }, 1.213 + { 1.214 + setup: 'tse #gcli-nomatch', 1.215 + check: { 1.216 + input: 'tse #gcli-nomatch', 1.217 + hints: ' [options]', 1.218 + markup: 'VVVVIIIIIIIIIIIII', 1.219 + cursor: 17, 1.220 + current: 'node', 1.221 + status: 'ERROR', 1.222 + args: { 1.223 + command: { name: 'tse' }, 1.224 + node: { 1.225 + value: undefined, 1.226 + arg: ' #gcli-nomatch', 1.227 + status: 'INCOMPLETE', 1.228 + message: 'No matches' 1.229 + }, 1.230 + nodes: { status: 'VALID' }, 1.231 + nodes2: { status: 'VALID' } 1.232 + } 1.233 + } 1.234 + } 1.235 + ]); 1.236 +}; 1.237 + 1.238 +exports.testNodes = function(options) { 1.239 + var requisition = options.requisition; 1.240 + 1.241 + return helpers.audit(options, [ 1.242 + { 1.243 + skipRemainingIf: options.isNoDom, 1.244 + setup: 'tse :root --nodes *', 1.245 + check: { 1.246 + input: 'tse :root --nodes *', 1.247 + hints: ' [options]', 1.248 + markup: 'VVVVVVVVVVVVVVVVVVV', 1.249 + current: 'nodes', 1.250 + status: 'VALID', 1.251 + args: { 1.252 + command: { name: 'tse' }, 1.253 + node: { arg: ' :root', status: 'VALID' }, 1.254 + nodes: { arg: ' --nodes *', status: 'VALID' }, 1.255 + nodes2: { status: 'VALID' } 1.256 + } 1.257 + }, 1.258 + post: function() { 1.259 + assert.is(requisition.getAssignment('node').value.tagName, 1.260 + 'HTML', 1.261 + '#gcli-input id'); 1.262 + } 1.263 + }, 1.264 + { 1.265 + setup: 'tse :root --nodes2 div', 1.266 + check: { 1.267 + input: 'tse :root --nodes2 div', 1.268 + hints: ' [options]', 1.269 + markup: 'VVVVVVVVVVVVVVVVVVVVVV', 1.270 + cursor: 22, 1.271 + current: 'nodes2', 1.272 + status: 'VALID', 1.273 + args: { 1.274 + command: { name: 'tse' }, 1.275 + node: { arg: ' :root', status: 'VALID' }, 1.276 + nodes: { status: 'VALID' }, 1.277 + nodes2: { arg: ' --nodes2 div', status: 'VALID' } 1.278 + } 1.279 + }, 1.280 + post: function() { 1.281 + assert.is(requisition.getAssignment('node').value.tagName, 1.282 + 'HTML', 1.283 + 'root id'); 1.284 + } 1.285 + }, 1.286 + { 1.287 + setup: 'tse --nodes ffff', 1.288 + check: { 1.289 + input: 'tse --nodes ffff', 1.290 + hints: ' <node> [options]', 1.291 + markup: 'VVVVIIIIIIIVIIII', 1.292 + cursor: 16, 1.293 + current: 'nodes', 1.294 + status: 'ERROR', 1.295 + args: { 1.296 + command: { name: 'tse' }, 1.297 + node: { 1.298 + value: undefined, 1.299 + arg: '', 1.300 + status: 'INCOMPLETE' 1.301 + }, 1.302 + nodes: { 1.303 + value: undefined, 1.304 + arg: ' --nodes ffff', 1.305 + status: 'INCOMPLETE', 1.306 + message: 'No matches' 1.307 + }, 1.308 + nodes2: { arg: '', status: 'VALID', message: '' } 1.309 + } 1.310 + }, 1.311 + post: function() { 1.312 + /* 1.313 + assert.is(requisition.getAssignment('nodes2').value.constructor.name, 1.314 + 'NodeList', 1.315 + '#gcli-input id'); 1.316 + */ 1.317 + } 1.318 + }, 1.319 + { 1.320 + setup: 'tse --nodes2 ffff', 1.321 + check: { 1.322 + input: 'tse --nodes2 ffff', 1.323 + hints: ' <node> [options]', 1.324 + markup: 'VVVVVVVVVVVVVVVVV', 1.325 + cursor: 17, 1.326 + current: 'nodes2', 1.327 + status: 'ERROR', 1.328 + args: { 1.329 + command: { name: 'tse' }, 1.330 + node: { 1.331 + value: undefined, 1.332 + arg: '', 1.333 + status: 'INCOMPLETE' 1.334 + }, 1.335 + nodes: { arg: '', status: 'VALID', message: '' }, 1.336 + nodes2: { arg: ' --nodes2 ffff', status: 'VALID', message: '' } 1.337 + } 1.338 + }, 1.339 + post: function() { 1.340 + /* 1.341 + assert.is(requisition.getAssignment('nodes').value.constructor.name, 1.342 + 'NodeList', 1.343 + '#gcli-input id'); 1.344 + assert.is(requisition.getAssignment('nodes2').value.constructor.name, 1.345 + 'NodeList', 1.346 + '#gcli-input id'); 1.347 + */ 1.348 + } 1.349 + }, 1.350 + ]); 1.351 +};