browser_gcli_cli2.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. */
  16. "use strict";
  17. // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
  18. // PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
  19. const exports = {};
  20. function test() {
  21. helpers.runTestModule(exports, "browser_gcli_cli2.js");
  22. }
  23. // var helpers = require('./helpers');
  24. exports.testSingleString = function (options) {
  25. return helpers.audit(options, [
  26. {
  27. setup: "tsr",
  28. check: {
  29. input: "tsr",
  30. hints: " <text>",
  31. markup: "VVV",
  32. cursor: 3,
  33. current: "__command",
  34. status: "ERROR",
  35. unassigned: [ ],
  36. args: {
  37. command: { name: "tsr" },
  38. text: {
  39. value: undefined,
  40. arg: "",
  41. status: "INCOMPLETE",
  42. message: "Value required for \u2018text\u2019."
  43. }
  44. }
  45. }
  46. },
  47. {
  48. setup: "tsr ",
  49. check: {
  50. input: "tsr ",
  51. hints: "<text>",
  52. markup: "VVVV",
  53. cursor: 4,
  54. current: "text",
  55. status: "ERROR",
  56. predictions: [ ],
  57. unassigned: [ ],
  58. args: {
  59. command: { name: "tsr" },
  60. text: {
  61. value: undefined,
  62. arg: "",
  63. status: "INCOMPLETE",
  64. message: "Value required for \u2018text\u2019."
  65. }
  66. }
  67. }
  68. },
  69. {
  70. setup: "tsr h",
  71. check: {
  72. input: "tsr h",
  73. hints: "",
  74. markup: "VVVVV",
  75. cursor: 5,
  76. current: "text",
  77. status: "VALID",
  78. predictions: [ ],
  79. unassigned: [ ],
  80. args: {
  81. command: { name: "tsr" },
  82. text: {
  83. value: "h",
  84. arg: " h",
  85. status: "VALID",
  86. message: ""
  87. }
  88. }
  89. }
  90. },
  91. {
  92. setup: 'tsr "h h"',
  93. check: {
  94. input: 'tsr "h h"',
  95. hints: "",
  96. markup: "VVVVVVVVV",
  97. cursor: 9,
  98. current: "text",
  99. status: "VALID",
  100. predictions: [ ],
  101. unassigned: [ ],
  102. args: {
  103. command: { name: "tsr" },
  104. text: {
  105. value: "h h",
  106. arg: ' "h h"',
  107. status: "VALID",
  108. message: ""
  109. }
  110. }
  111. }
  112. },
  113. {
  114. setup: "tsr h h h",
  115. check: {
  116. input: "tsr h h h",
  117. hints: "",
  118. markup: "VVVVVVVVV",
  119. cursor: 9,
  120. current: "text",
  121. status: "VALID",
  122. predictions: [ ],
  123. unassigned: [ ],
  124. args: {
  125. command: { name: "tsr" },
  126. text: {
  127. value: "h h h",
  128. arg: " h h h",
  129. status: "VALID",
  130. message: ""
  131. }
  132. }
  133. }
  134. }
  135. ]);
  136. };
  137. exports.testSingleNumber = function (options) {
  138. return helpers.audit(options, [
  139. {
  140. setup: "tsu",
  141. check: {
  142. input: "tsu",
  143. hints: " <num>",
  144. markup: "VVV",
  145. cursor: 3,
  146. current: "__command",
  147. status: "ERROR",
  148. predictions: [ ],
  149. unassigned: [ ],
  150. args: {
  151. command: { name: "tsu" },
  152. num: {
  153. value: undefined,
  154. arg: "",
  155. status: "INCOMPLETE",
  156. message: "Value required for \u2018num\u2019."
  157. }
  158. }
  159. }
  160. },
  161. {
  162. setup: "tsu ",
  163. check: {
  164. input: "tsu ",
  165. hints: "<num>",
  166. markup: "VVVV",
  167. cursor: 4,
  168. current: "num",
  169. status: "ERROR",
  170. predictions: [ ],
  171. unassigned: [ ],
  172. args: {
  173. command: { name: "tsu" },
  174. num: {
  175. value: undefined,
  176. arg: "",
  177. status: "INCOMPLETE",
  178. message: "Value required for \u2018num\u2019."
  179. }
  180. }
  181. }
  182. },
  183. {
  184. setup: "tsu 1",
  185. check: {
  186. input: "tsu 1",
  187. hints: "",
  188. markup: "VVVVV",
  189. cursor: 5,
  190. current: "num",
  191. status: "VALID",
  192. predictions: [ ],
  193. unassigned: [ ],
  194. args: {
  195. command: { name: "tsu" },
  196. num: { value: 1, arg: " 1", status: "VALID", message: "" }
  197. }
  198. }
  199. },
  200. {
  201. setup: "tsu x",
  202. check: {
  203. input: "tsu x",
  204. hints: "",
  205. markup: "VVVVE",
  206. cursor: 5,
  207. current: "num",
  208. status: "ERROR",
  209. predictions: [ ],
  210. unassigned: [ ],
  211. tooltipState: "true:isError",
  212. args: {
  213. command: { name: "tsu" },
  214. num: {
  215. value: undefined,
  216. arg: " x",
  217. status: "ERROR",
  218. message: "Can\u2019t convert \u201cx\u201d to a number."
  219. }
  220. }
  221. }
  222. },
  223. {
  224. setup: "tsu 1.5",
  225. check: {
  226. input: "tsu 1.5",
  227. hints: "",
  228. markup: "VVVVEEE",
  229. cursor: 7,
  230. current: "num",
  231. status: "ERROR",
  232. predictions: [ ],
  233. unassigned: [ ],
  234. args: {
  235. command: { name: "tsu" },
  236. num: {
  237. value: undefined,
  238. arg: " 1.5",
  239. status: "ERROR",
  240. message: "Can\u2019t convert \u201c1.5\u201d to an integer."
  241. }
  242. }
  243. }
  244. }
  245. ]);
  246. };
  247. exports.testSingleFloat = function (options) {
  248. return helpers.audit(options, [
  249. {
  250. setup: "tsf",
  251. check: {
  252. input: "tsf",
  253. hints: " <num>",
  254. markup: "VVV",
  255. cursor: 3,
  256. current: "__command",
  257. status: "ERROR",
  258. error: "",
  259. unassigned: [ ],
  260. args: {
  261. command: { name: "tsf" },
  262. num: {
  263. value: undefined,
  264. arg: "",
  265. status: "INCOMPLETE",
  266. message: "Value required for \u2018num\u2019."
  267. }
  268. }
  269. }
  270. },
  271. {
  272. setup: "tsf 1",
  273. check: {
  274. input: "tsf 1",
  275. hints: "",
  276. markup: "VVVVV",
  277. cursor: 5,
  278. current: "num",
  279. status: "VALID",
  280. error: "",
  281. predictions: [ ],
  282. unassigned: [ ],
  283. args: {
  284. command: { name: "tsf" },
  285. num: { value: 1, arg: " 1", status: "VALID", message: "" }
  286. }
  287. }
  288. },
  289. {
  290. setup: "tsf 1.",
  291. check: {
  292. input: "tsf 1.",
  293. hints: "",
  294. markup: "VVVVVV",
  295. cursor: 6,
  296. current: "num",
  297. status: "VALID",
  298. error: "",
  299. predictions: [ ],
  300. unassigned: [ ],
  301. args: {
  302. command: { name: "tsf" },
  303. num: { value: 1, arg: " 1.", status: "VALID", message: "" }
  304. }
  305. }
  306. },
  307. {
  308. setup: "tsf 1.5",
  309. check: {
  310. input: "tsf 1.5",
  311. hints: "",
  312. markup: "VVVVVVV",
  313. cursor: 7,
  314. current: "num",
  315. status: "VALID",
  316. error: "",
  317. predictions: [ ],
  318. unassigned: [ ],
  319. args: {
  320. command: { name: "tsf" },
  321. num: { value: 1.5, arg: " 1.5", status: "VALID", message: "" }
  322. }
  323. }
  324. },
  325. {
  326. setup: "tsf 1.5x",
  327. check: {
  328. input: "tsf 1.5x",
  329. hints: "",
  330. markup: "VVVVVVVV",
  331. cursor: 8,
  332. current: "num",
  333. status: "VALID",
  334. error: "",
  335. predictions: [ ],
  336. unassigned: [ ],
  337. args: {
  338. command: { name: "tsf" },
  339. num: { value: 1.5, arg: " 1.5x", status: "VALID", message: "" }
  340. }
  341. }
  342. },
  343. {
  344. name: "tsf x (cursor=4)",
  345. setup: function () {
  346. return helpers.setInput(options, "tsf x", 4);
  347. },
  348. check: {
  349. input: "tsf x",
  350. hints: "",
  351. markup: "VVVVE",
  352. cursor: 4,
  353. current: "num",
  354. status: "ERROR",
  355. error: "Can\u2019t convert \u201cx\u201d to a number.",
  356. predictions: [ ],
  357. unassigned: [ ],
  358. args: {
  359. command: { name: "tsf" },
  360. num: {
  361. value: undefined,
  362. arg: " x",
  363. status: "ERROR",
  364. message: "Can\u2019t convert \u201cx\u201d to a number."
  365. }
  366. }
  367. }
  368. }
  369. ]);
  370. };
  371. exports.testElementWeb = function (options) {
  372. return helpers.audit(options, [
  373. {
  374. setup: "tse #gcli-root",
  375. check: {
  376. input: "tse #gcli-root",
  377. hints: " [options]",
  378. markup: "VVVVVVVVVVVVVV",
  379. cursor: 14,
  380. current: "node",
  381. status: "VALID",
  382. predictions: [ ],
  383. unassigned: [ ],
  384. args: {
  385. command: { name: "tse" },
  386. node: {
  387. arg: " #gcli-root",
  388. status: "VALID",
  389. message: ""
  390. },
  391. nodes: { arg: "", status: "VALID", message: "" },
  392. nodes2: { arg: "", status: "VALID", message: "" },
  393. }
  394. }
  395. }
  396. ]);
  397. };
  398. exports.testElement = function (options) {
  399. return helpers.audit(options, [
  400. {
  401. setup: "tse",
  402. check: {
  403. input: "tse",
  404. hints: " <node> [options]",
  405. markup: "VVV",
  406. cursor: 3,
  407. current: "__command",
  408. status: "ERROR",
  409. predictions: [ "tse", "tselarr" ],
  410. unassigned: [ ],
  411. args: {
  412. command: { name: "tse" },
  413. node: { arg: "", status: "INCOMPLETE" },
  414. nodes: { arg: "", status: "VALID", message: "" },
  415. nodes2: { arg: "", status: "VALID", message: "" },
  416. }
  417. }
  418. },
  419. {
  420. setup: "tse #gcli-nomatch",
  421. check: {
  422. input: "tse #gcli-nomatch",
  423. hints: " [options]",
  424. markup: "VVVVIIIIIIIIIIIII",
  425. cursor: 17,
  426. current: "node",
  427. status: "ERROR",
  428. predictions: [ ],
  429. unassigned: [ ],
  430. outputState: "false:default",
  431. tooltipState: "true:isError",
  432. args: {
  433. command: { name: "tse" },
  434. node: {
  435. value: undefined,
  436. arg: " #gcli-nomatch",
  437. // This is somewhat debatable because this input can't be corrected
  438. // simply by typing so it's and error rather than incomplete,
  439. // however without digging into the CSS engine we can't tell that
  440. // so we default to incomplete
  441. status: "INCOMPLETE",
  442. message: "No matches"
  443. },
  444. nodes: { arg: "", status: "VALID", message: "" },
  445. nodes2: { arg: "", status: "VALID", message: "" },
  446. }
  447. }
  448. },
  449. {
  450. setup: "tse #",
  451. check: {
  452. input: "tse #",
  453. hints: " [options]",
  454. markup: "VVVVE",
  455. cursor: 5,
  456. current: "node",
  457. status: "ERROR",
  458. predictions: [ ],
  459. unassigned: [ ],
  460. tooltipState: "true:isError",
  461. args: {
  462. command: { name: "tse" },
  463. node: {
  464. value: undefined,
  465. arg: " #",
  466. status: "ERROR",
  467. message: "Syntax error in CSS query"
  468. },
  469. nodes: { arg: "", status: "VALID", message: "" },
  470. nodes2: { arg: "", status: "VALID", message: "" },
  471. }
  472. }
  473. },
  474. {
  475. setup: "tse .",
  476. check: {
  477. input: "tse .",
  478. hints: " [options]",
  479. markup: "VVVVE",
  480. cursor: 5,
  481. current: "node",
  482. status: "ERROR",
  483. predictions: [ ],
  484. unassigned: [ ],
  485. tooltipState: "true:isError",
  486. args: {
  487. command: { name: "tse" },
  488. node: {
  489. value: undefined,
  490. arg: " .",
  491. status: "ERROR",
  492. message: "Syntax error in CSS query"
  493. },
  494. nodes: { arg: "", status: "VALID", message: "" },
  495. nodes2: { arg: "", status: "VALID", message: "" },
  496. }
  497. }
  498. },
  499. {
  500. setup: "tse *",
  501. check: {
  502. input: "tse *",
  503. hints: " [options]",
  504. markup: "VVVVE",
  505. cursor: 5,
  506. current: "node",
  507. status: "ERROR",
  508. predictions: [ ],
  509. unassigned: [ ],
  510. tooltipState: "true:isError",
  511. args: {
  512. command: { name: "tse" },
  513. node: {
  514. value: undefined,
  515. arg: " *",
  516. status: "ERROR",
  517. message: /^Too many matches \([0-9]*\)/
  518. },
  519. nodes: { arg: "", status: "VALID", message: "" },
  520. nodes2: { arg: "", status: "VALID", message: "" },
  521. }
  522. }
  523. }
  524. ]);
  525. };
  526. exports.testNestedCommand = function (options) {
  527. return helpers.audit(options, [
  528. {
  529. setup: "tsn",
  530. check: {
  531. input: "tsn",
  532. hints: " deep down nested cmd",
  533. markup: "III",
  534. cursor: 3,
  535. current: "__command",
  536. status: "ERROR",
  537. predictionsInclude: [
  538. "tsn deep", "tsn deep down", "tsn deep down nested",
  539. "tsn deep down nested cmd", "tsn dif"
  540. ],
  541. unassigned: [ ],
  542. args: {
  543. command: { name: "tsn" }
  544. }
  545. }
  546. },
  547. {
  548. setup: "tsn ",
  549. check: {
  550. input: "tsn ",
  551. hints: " deep down nested cmd",
  552. markup: "IIIV",
  553. cursor: 4,
  554. current: "__command",
  555. status: "ERROR",
  556. unassigned: [ ]
  557. }
  558. },
  559. {
  560. skipIf: options.isPhantomjs, // PhantomJS gets predictions wrong
  561. setup: "tsn x",
  562. check: {
  563. input: "tsn x",
  564. hints: " -> tsn ext",
  565. markup: "IIIVI",
  566. cursor: 5,
  567. current: "__command",
  568. status: "ERROR",
  569. predictions: [ "tsn ext" ],
  570. unassigned: [ ]
  571. }
  572. },
  573. {
  574. setup: "tsn dif",
  575. check: {
  576. input: "tsn dif",
  577. hints: " <text>",
  578. markup: "VVVVVVV",
  579. cursor: 7,
  580. current: "__command",
  581. status: "ERROR",
  582. predictions: [ ],
  583. unassigned: [ ],
  584. args: {
  585. command: { name: "tsn dif" },
  586. text: {
  587. value: undefined,
  588. arg: "",
  589. status: "INCOMPLETE",
  590. message: "Value required for \u2018text\u2019."
  591. }
  592. }
  593. }
  594. },
  595. {
  596. setup: "tsn dif ",
  597. check: {
  598. input: "tsn dif ",
  599. hints: "<text>",
  600. markup: "VVVVVVVV",
  601. cursor: 8,
  602. current: "text",
  603. status: "ERROR",
  604. predictions: [ ],
  605. unassigned: [ ],
  606. args: {
  607. command: { name: "tsn dif" },
  608. text: {
  609. value: undefined,
  610. arg: "",
  611. status: "INCOMPLETE",
  612. message: "Value required for \u2018text\u2019."
  613. }
  614. }
  615. }
  616. },
  617. {
  618. setup: "tsn dif x",
  619. check: {
  620. input: "tsn dif x",
  621. hints: "",
  622. markup: "VVVVVVVVV",
  623. cursor: 9,
  624. current: "text",
  625. status: "VALID",
  626. predictions: [ ],
  627. unassigned: [ ],
  628. args: {
  629. command: { name: "tsn dif" },
  630. text: { value: "x", arg: " x", status: "VALID", message: "" }
  631. }
  632. }
  633. },
  634. {
  635. setup: "tsn ext",
  636. check: {
  637. input: "tsn ext",
  638. hints: " <text>",
  639. markup: "VVVVVVV",
  640. cursor: 7,
  641. current: "__command",
  642. status: "ERROR",
  643. predictions: [ "tsn ext", "tsn exte", "tsn exten", "tsn extend" ],
  644. unassigned: [ ],
  645. args: {
  646. command: { name: "tsn ext" },
  647. text: {
  648. value: undefined,
  649. arg: "",
  650. status: "INCOMPLETE",
  651. message: "Value required for \u2018text\u2019."
  652. }
  653. }
  654. }
  655. },
  656. {
  657. setup: "tsn exte",
  658. check: {
  659. input: "tsn exte",
  660. hints: " <text>",
  661. markup: "VVVVVVVV",
  662. cursor: 8,
  663. current: "__command",
  664. status: "ERROR",
  665. predictions: [ "tsn exte", "tsn exten", "tsn extend" ],
  666. unassigned: [ ],
  667. args: {
  668. command: { name: "tsn exte" },
  669. text: {
  670. value: undefined,
  671. arg: "",
  672. status: "INCOMPLETE",
  673. message: "Value required for \u2018text\u2019."
  674. }
  675. }
  676. }
  677. },
  678. {
  679. setup: "tsn exten",
  680. check: {
  681. input: "tsn exten",
  682. hints: " <text>",
  683. markup: "VVVVVVVVV",
  684. cursor: 9,
  685. current: "__command",
  686. status: "ERROR",
  687. predictions: [ "tsn exten", "tsn extend" ],
  688. unassigned: [ ],
  689. args: {
  690. command: { name: "tsn exten" },
  691. text: {
  692. value: undefined,
  693. arg: "",
  694. status: "INCOMPLETE",
  695. message: "Value required for \u2018text\u2019."
  696. }
  697. }
  698. }
  699. },
  700. {
  701. setup: "tsn extend",
  702. check: {
  703. input: "tsn extend",
  704. hints: " <text>",
  705. markup: "VVVVVVVVVV",
  706. cursor: 10,
  707. current: "__command",
  708. status: "ERROR",
  709. predictions: [ ],
  710. unassigned: [ ],
  711. args: {
  712. command: { name: "tsn extend" },
  713. text: {
  714. value: undefined,
  715. arg: "",
  716. status: "INCOMPLETE",
  717. message: "Value required for \u2018text\u2019."
  718. }
  719. }
  720. }
  721. },
  722. {
  723. setup: "ts ",
  724. check: {
  725. input: "ts ",
  726. hints: "",
  727. markup: "EEV",
  728. cursor: 3,
  729. current: "__command",
  730. status: "ERROR",
  731. predictions: [ ],
  732. unassigned: [ ],
  733. tooltipState: "true:isError"
  734. }
  735. },
  736. ]);
  737. };
  738. // From Bug 664203
  739. exports.testDeeplyNested = function (options) {
  740. return helpers.audit(options, [
  741. {
  742. setup: "tsn deep down nested",
  743. check: {
  744. input: "tsn deep down nested",
  745. hints: " cmd",
  746. markup: "IIIVIIIIVIIIIVIIIIII",
  747. cursor: 20,
  748. current: "__command",
  749. status: "ERROR",
  750. predictions: [ "tsn deep down nested cmd" ],
  751. unassigned: [ ],
  752. outputState: "false:default",
  753. tooltipState: "false:default",
  754. args: {
  755. command: { name: "tsn deep down nested" },
  756. }
  757. }
  758. },
  759. {
  760. setup: "tsn deep down nested cmd",
  761. check: {
  762. input: "tsn deep down nested cmd",
  763. hints: "",
  764. markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
  765. cursor: 24,
  766. current: "__command",
  767. status: "VALID",
  768. predictions: [ ],
  769. unassigned: [ ],
  770. args: {
  771. command: { name: "tsn deep down nested cmd" },
  772. }
  773. }
  774. }
  775. ]);
  776. };