import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,85 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.gcli-help-name {
text-align: end;
}
.gcli-out-shortcut,
.gcli-help-synopsis {
cursor: pointer;
display: inline-block;
}
.gcli-out-shortcut:before,
.gcli-help-synopsis:before {
content: '\bb';
}
.gcli-menu-template {
white-space: nowrap;
width: 290px;
display: flex;
}
.gcli-menu-names {
white-space: nowrap;
flex-grow: 0;
flex-shrink: 0;
}
.gcli-menu-descs {
flex-grow: 1;
flex-shrink: 1;
}
.gcli-menu-name,
.gcli-menu-desc {
white-space: nowrap;
}
.gcli-menu-name {
padding-inline-end: 10px;
}
.gcli-menu-desc {
text-overflow: ellipsis;
overflow: hidden;
}
.gcli-menu-name,
.gcli-out-shortcut,
.gcli-help-synopsis {
direction: ltr;
}
.gcli-cookielist-list {
list-style-type: none;
padding-left: 0;
}
.gcli-cookielist-detail {
padding-left: 20px;
padding-bottom: 10px;
}
.gcli-appcache-list {
list-style-type: none;
padding-left: 0;
}
.gcli-appcache-detail {
padding-left: 20px;
padding-bottom: 10px;
}
.gcli-row-out .nowrap {
white-space: nowrap;
}
.gcli-mdn-url {
text-decoration: underline;
cursor: pointer;
}

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="chrome://devtools/content/commandline/commandline.css" type="text/css"/>
<link rel="stylesheet" href="chrome://devtools/skin/commandline.css" type="text/css"/>
</head>
<body class="gcli-body">
<div id="gcli-output-root"></div>
</body>
</html>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="chrome://devtools/content/commandline/commandline.css" type="text/css"/>
<link rel="stylesheet" href="chrome://devtools/skin/commandline.css" type="text/css"/>
</head>
<body class="gcli-body">
<div id="gcli-tooltip-root"></div>
<div id="gcli-tooltip-connector"></div>
</body>
</html>

View file

@ -0,0 +1,5 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']

View file

@ -0,0 +1,10 @@
"use strict";
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../.eslintrc.mochitests.js",
"globals": {
"helpers": true,
"assert": true
}
};

View file

@ -0,0 +1,124 @@
[DEFAULT]
skip-if = e10s # Bug 1034511
tags = devtools
subsuite = devtools
support-files =
head.js
helpers.js
mockCommands.js
[browser_cmd_addon.js]
[browser_cmd_calllog.js]
skip-if = true # Bug 845831
[browser_cmd_calllog_chrome.js]
skip-if = true # Bug 845831
[browser_cmd_appcache_invalid.js]
support-files =
browser_cmd_appcache_invalid_appcache.appcache
browser_cmd_appcache_invalid_appcache.appcache^headers^
browser_cmd_appcache_invalid_index.html
browser_cmd_appcache_invalid_page1.html
browser_cmd_appcache_invalid_page2.html
browser_cmd_appcache_invalid_page3.html
browser_cmd_appcache_invalid_page3.html^headers^
[browser_cmd_appcache_valid.js]
support-files =
browser_cmd_appcache_valid_appcache.appcache
browser_cmd_appcache_valid_appcache.appcache^headers^
browser_cmd_appcache_valid_index.html
browser_cmd_appcache_valid_page1.html
browser_cmd_appcache_valid_page2.html
browser_cmd_appcache_valid_page3.html
[browser_cmd_commands.js]
[browser_cmd_cookie.js]
support-files =
browser_cmd_cookie.html
[browser_cmd_cookie_host.js]
support-files =
browser_cmd_cookie.html
[browser_cmd_csscoverage_oneshot.js]
support-files =
browser_cmd_csscoverage_page1.html
browser_cmd_csscoverage_page2.html
browser_cmd_csscoverage_page3.html
browser_cmd_csscoverage_sheetA.css
browser_cmd_csscoverage_sheetB.css
browser_cmd_csscoverage_sheetC.css
browser_cmd_csscoverage_sheetD.css
[browser_cmd_csscoverage_startstop.js]
support-files =
browser_cmd_csscoverage_page1.html
browser_cmd_csscoverage_page2.html
browser_cmd_csscoverage_page3.html
browser_cmd_csscoverage_sheetA.css
browser_cmd_csscoverage_sheetB.css
browser_cmd_csscoverage_sheetC.css
browser_cmd_csscoverage_sheetD.css
[browser_cmd_folder.js]
skip-if = (e10s && debug) # Bug 1034511 (docShell leaks on debug)
[browser_cmd_highlight_01.js]
[browser_cmd_highlight_02.js]
[browser_cmd_highlight_03.js]
[browser_cmd_highlight_04.js]
[browser_cmd_inject.js]
support-files =
browser_cmd_inject.html
[browser_cmd_csscoverage_util.js]
skip-if = (e10s && debug) # Bug 1034511 (docShell leaks on debug)
[browser_cmd_jsb.js]
support-files =
browser_cmd_jsb_script.jsi
[browser_cmd_listen.js]
[browser_cmd_measure.js]
[browser_cmd_media.js]
support-files =
browser_cmd_media.html
[browser_cmd_pagemod_export.js]
support-files =
browser_cmd_pagemod_export.html
[browser_cmd_paintflashing.js]
[browser_cmd_pref1.js]
[browser_cmd_pref2.js]
[browser_cmd_pref3.js]
[browser_cmd_qsa.js]
[browser_cmd_restart.js]
[browser_cmd_rulers.js]
[browser_cmd_screenshot.js]
subsuite = clipboard
support-files =
browser_cmd_screenshot.html
[browser_cmd_settings.js]
[browser_gcli_async.js]
[browser_gcli_canon.js]
[browser_gcli_cli1.js]
[browser_gcli_cli2.js]
[browser_gcli_completion1.js]
[browser_gcli_completion2.js]
[browser_gcli_date.js]
skip-if = true # Bug 934098
[browser_gcli_exec.js]
[browser_gcli_fail.js]
[browser_gcli_file.js]
[browser_gcli_focus.js]
[browser_gcli_history.js]
[browser_gcli_incomplete.js]
[browser_gcli_inputter.js]
skip-if = true # Bug 1093205 - Test does not run in Firefox due to missing terminal bug
[browser_gcli_intro.js]
[browser_gcli_js.js]
[browser_gcli_keyboard1.js]
[browser_gcli_keyboard2.js]
[browser_gcli_keyboard3.js]
[browser_gcli_keyboard4.js]
[browser_gcli_keyboard5.js]
[browser_gcli_menu.js]
[browser_gcli_node.js]
[browser_gcli_resource.js]
[browser_gcli_short.js]
[browser_gcli_spell.js]
[browser_gcli_split.js]
[browser_gcli_tokenize.js]
[browser_gcli_tooltip.js]
skip-if = true # Bug 1093205 - Test does not run in Firefox due to missing terminal
[browser_gcli_types.js]
[browser_gcli_union.js]

View file

@ -0,0 +1,195 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the addon commands works as they should
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab("about:blank");
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "addon list dictionary",
check: {
input: "addon list dictionary",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "There are no add-ons of that type installed."
}
},
{
setup: "addon list extension",
check: {
input: "addon list extension",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: [/The following/, /Mochitest/, /Special Powers/]
}
},
{
setup: "addon list locale",
check: {
input: "addon list locale",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "There are no add-ons of that type installed."
}
},
{
setup: "addon list plugin",
check: {
input: "addon list plugin",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: [/Test Plug-in/, /Second Test Plug-in/]
}
},
{
setup: "addon list theme",
check: {
input: "addon list theme",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: [/following themes/, /Default/]
}
},
{
setup: "addon list all",
check: {
input: "addon list all",
hints: "",
markup: "VVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: [/The following/, /Default/, /Mochitest/, /Test Plug-in/,
/Second Test Plug-in/, /Special Powers/]
}
},
{
setup: "addon disable Test_Plug-in_1.0.0.0",
check: {
input: "addon disable Test_Plug-in_1.0.0.0",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "Test Plug-in 1.0.0.0 disabled."
}
},
{
setup: "addon disable WRONG",
check: {
input: "addon disable WRONG",
hints: "",
markup: "VVVVVVVVVVVVVVEEEEE",
status: "ERROR"
}
},
{
setup: "addon enable Test_Plug-in_1.0.0.0",
check: {
input: "addon enable Test_Plug-in_1.0.0.0",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
command: { name: "addon enable" },
addon: {
value: function (addon) {
is(addon.name, "Test Plug-in", "test plugin name");
},
status: "VALID"
}
}
},
exec: {
output: "Test Plug-in 1.0.0.0 enabled."
}
},
{
setup: "addon ctp Test_Plug-in_1.0.0.0",
check: {
input: "addon ctp Test_Plug-in_1.0.0.0",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
command: { name: "addon ctp" },
addon: {
value: function (addon) {
is(addon.name, "Test Plug-in", "test plugin name");
},
status: "VALID"
}
}
},
exec: {
output: "Test Plug-in 1.0.0.0 set to click-to-play."
}
},
{
setup: "addon ctp OpenH264_Video_Codec_provided_by_Cisco_Systems,_Inc._null",
check: {
input: "addon ctp OpenH264_Video_Codec_provided_by_Cisco_Systems,_Inc._null",
hints: "",
status: "VALID",
args: {
command: { name: "addon ctp" },
addon: {
value: function (addon) {
is(addon.name, "OpenH264 Video Codec provided by Cisco Systems, Inc.", "openh264");
},
status: "VALID"
}
}
},
exec: {
output: "OpenH264 Video Codec provided by Cisco Systems, Inc. null cannot be set to click-to-play."
}
},
{
setup: "addon ctp Mochitest_1.0",
check: {
input: "addon ctp Mochitest_1.0",
hints: "",
status: "VALID",
args: {
command: { name: "addon ctp" },
addon: {
value: function (addon) {
is(addon.name, "Mochitest", "mochitest");
},
status: "VALID"
}
}
},
exec: {
output: "Mochitest 1.0 cannot be set to click-to-play because it is not a plugin."
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,134 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the appcache validate works as they should with an invalid
// manifest.
const TEST_URI = "http://sub1.test1.example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_appcache_invalid_index.html";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let lines = [
"Manifest has a character encoding of ISO-8859-1. Manifests must have the " +
"utf-8 character encoding.",
"The first line of the manifest must be \u201cCACHE MANIFEST\u201d at line 1.",
"\u201cCACHE MANIFEST\u201d is only valid on the first line but was found at line 3.",
"images/sound-icon.png points to a resource that is not available at line 9.",
"images/background.png points to a resource that is not available at line 10.",
"/checking.cgi points to a resource that is not available at line 13.",
"Asterisk (*) incorrectly used in the NETWORK section at line 14. If a line " +
"in the NETWORK section contains only a single asterisk character, then any " +
"URI not listed in the manifest will be treated as if the URI was listed in " +
"the NETWORK section. Otherwise such URIs will be treated as unavailable. " +
"Other uses of the * character are prohibited",
"../rel.html points to a resource that is not available at line 17.",
"../../rel.html points to a resource that is not available at line 18.",
"../../../rel.html points to a resource that is not available at line 19.",
"../../../../rel.html points to a resource that is not available at line 20.",
"../../../../../rel.html points to a resource that is not available at line 21.",
"/../ is not a valid URI prefix at line 22.",
"/test.css points to a resource that is not available at line 23.",
"/test.js points to a resource that is not available at line 24.",
"test.png points to a resource that is not available at line 25.",
"/main/features.js points to a resource that is not available at line 27.",
"/main/settings/index.css points to a resource that is not available at line 28.",
"http://example.com/scene.jpg points to a resource that is not available at line 29.",
"/section1/blockedbyfallback.html points to a resource that is not available at line 30.",
"http://example.com/images/world.jpg points to a resource that is not available at line 31.",
"/section2/blockedbyfallback.html points to a resource that is not available at line 32.",
"/main/home points to a resource that is not available at line 34.",
"main/app.js points to a resource that is not available at line 35.",
"/settings/home points to a resource that is not available at line 37.",
"/settings/app.js points to a resource that is not available at line 38.",
"The file http://sub1.test1.example.com/browser/devtools/client/" +
"commandline/test/browser_cmd_appcache_invalid_page3.html was modified " +
"after http://sub1.test1.example.com/browser/devtools/client/" +
"commandline/test/browser_cmd_appcache_invalid_appcache.appcache. Unless " +
"the text in the manifest file is changed the cached version will be used " +
"instead at line 39.",
"browser_cmd_appcache_invalid_page3.html has cache-control set to no-store. " +
"This will prevent the application cache from storing the file at line 39.",
"http://example.com/logo.png points to a resource that is not available at line 40.",
"http://example.com/check.png points to a resource that is not available at line 41.",
"Spaces in URIs need to be replaced with % at line 42.",
"http://example.com/cr oss.png points to a resource that is not available at line 42.",
"Asterisk (*) incorrectly used in the CACHE section at line 43. If a line " +
"in the NETWORK section contains only a single asterisk character, then " +
"any URI not listed in the manifest will be treated as if the URI was " +
"listed in the NETWORK section. Otherwise such URIs will be treated as " +
"unavailable. Other uses of the * character are prohibited",
"The SETTINGS section may only contain a single value, \u201cprefer-online\u201d or \u201cfast\u201d at line 47.",
"FALLBACK section line 50 (/section1/ /offline1.html) prevents caching of " +
"line 30 (/section1/blockedbyfallback.html) in the CACHE section.",
"/offline1.html points to a resource that is not available at line 50.",
"FALLBACK section line 51 (/section2/ offline2.html) prevents caching of " +
"line 32 (/section2/blockedbyfallback.html) in the CACHE section.",
"offline2.html points to a resource that is not available at line 51.",
"Only two URIs separated by spaces are allowed in the FALLBACK section at line 52.",
"Asterisk (*) incorrectly used in the FALLBACK section at line 53. URIs " +
"in the FALLBACK section simply need to match a prefix of the request URI.",
"offline3.html points to a resource that is not available at line 53.",
"Invalid section name (BLAH) at line 55.",
"Only two URIs separated by spaces are allowed in the FALLBACK section at line 55."
];
let options = yield helpers.openTab(TEST_URI);
info("window open");
// Wait for site to be cached.
yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, "error");
info("applicationCache error happened");
yield helpers.openToolbar(options);
info("toolbar open");
// Pages containing an appcache the notification bar gives options to allow
// or deny permission for the app to save data offline. Let's click Allow.
let notificationID = "offline-app-requested-sub1.test1.example.com";
let notification =
PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser);
if (notification) {
info("Authorizing offline storage.");
notification.mainAction.callback();
} else {
info("No notification box is available.");
}
info("Site now cached, running tests.");
yield helpers.audit(options, [
{
setup: "appcache validate",
check: {
input: "appcache validate",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID",
args: {}
},
exec: {
output: lines.map(getRegexForString)
},
},
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}
/**
* Creates a regular expression that matches a string. This greatly simplifies
* matching and debugging long strings.
*
* @param {String} text
* Text to convert
* @return {RegExp}
* Regular expression matching text
*/
function getRegexForString(str) {
str = str.replace(/(\.|\\|\/|\(|\)|\[|\]|\*|\+|\?|\$|\^|\|)/g, "\\$1");
return new RegExp(str);
}

View file

@ -0,0 +1,55 @@
# some comment
CACHE MANIFEST
# the above is a required line
# this is a comment
# spaces are ignored
# blank lines are ignored
images/sound-icon.png
images/background.png
NETWORK:
/checking.cgi
/checking.*
CACHE:
../rel.html
../../rel.html
../../../rel.html
../../../../rel.html
../../../../../rel.html
/../invalid.html
/test.css
/test.js
test.png
browser_cmd_appcache_invalid_index.html
/main/features.js
/main/settings/index.css
http://example.com/scene.jpg
/section1/blockedbyfallback.html
http://example.com/images/world.jpg
/section2/blockedbyfallback.html
browser_cmd_appcache_invalid_page1.html
/main/home
main/app.js
browser_cmd_appcache_invalid_page2.html
/settings/home
/settings/app.js
browser_cmd_appcache_invalid_page3.html
http://example.com/logo.png
http://example.com/check.png
http://example.com/cr oss.png
/checking*.png
SETTINGS:
prefer-online
fast
FALLBACK:
/section1/ /offline1.html
/section2/ offline2.html
dadsdsd
* offline3.html
BLAH:

View file

@ -0,0 +1,2 @@
Content-Type: text/cache-manifest; charset=ISO-8859-1
Last-Modified: Tue, 23 Apr 9998 11:41:13 GMT

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_invalid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example index.html</h1>
<br />
<a href="browser_cmd_appcache_invalid_index.html">Home</a> |
<a href="browser_cmd_appcache_invalid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_invalid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_invalid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_invalid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page1.html</h1>
<br />
<a href="browser_cmd_appcache_invalid_index.html">Home</a> |
<a href="browser_cmd_appcache_invalid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_invalid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_invalid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_invalid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page2.html</h1>
<br />
<a href="browser_cmd_appcache_invalid_index.html">Home</a> |
<a href="browser_cmd_appcache_invalid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_invalid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_invalid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_invalid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page3.html</h1>
<br />
<a href="browser_cmd_appcache_invalid_index.html">Home</a> |
<a href="browser_cmd_appcache_invalid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_invalid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_invalid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,2 @@
Cache-Control: no-store, no-cache
Last-Modified: Tue, 23 Apr 9999 11:41:13 GMT

View file

@ -0,0 +1,173 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the appcache commands works as they should
const TEST_URI = "http://sub1.test2.example.com/browser/devtools/client/" +
"commandline/test/browser_cmd_appcache_valid_index.html";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
info("adding cache listener.");
// Wait for site to be cached.
yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, "cached");
yield helpers.openToolbar(options);
// Pages containing an appcache the notification bar gives options to allow
// or deny permission for the app to save data offline. Let's click Allow.
let notificationID = "offline-app-requested-sub1.test2.example.com";
let notification = PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser);
if (notification) {
info("Authorizing offline storage.");
notification.mainAction.callback();
} else {
info("No notification box is available.");
}
info("Site now cached, running tests.");
yield helpers.audit(options, [
{
setup: "appcache",
check: {
input: "appcache",
markup: "IIIIIIII",
status: "ERROR",
args: {}
},
},
{
setup: function () {
Services.prefs.setBoolPref("browser.cache.disk.enable", false);
return helpers.setInput(options, "appcache list", 13);
},
check: {
input: "appcache list",
markup: "VVVVVVVVVVVVV",
status: "VALID",
args: {},
},
exec: {
output: [ /cache is disabled/ ]
},
post: function (output) {
Services.prefs.setBoolPref("browser.cache.disk.enable", true);
}
},
{
setup: "appcache list",
check: {
input: "appcache list",
markup: "VVVVVVVVVVVVV",
status: "VALID",
args: {},
},
exec: {
output: [ /index/, /page1/, /page2/, /page3/ ]
},
},
{
setup: "appcache list page",
check: {
input: "appcache list page",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
search: { value: "page" },
}
},
exec: {
output: [ /page1/, /page2/, /page3/ ]
},
post: function (output, text) {
ok(!text.includes("index"), "index is not contained in output");
}
},
{
setup: "appcache validate",
check: {
input: "appcache validate",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID",
args: {}
},
exec: {
output: [ /successfully/ ]
},
},
{
setup: "appcache validate " + TEST_URI,
check: {
input: "appcache validate " + TEST_URI,
// appcache validate http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
uri: {
value: TEST_URI
},
}
},
exec: {
output: [ /successfully/ ]
},
},
{
setup: "appcache clear",
check: {
input: "appcache clear",
markup: "VVVVVVVVVVVVVV",
status: "VALID",
args: {},
},
exec: {
output: [ /successfully/ ]
},
},
{
setup: "appcache list",
check: {
input: "appcache list",
markup: "VVVVVVVVVVVVV",
status: "VALID",
args: {},
},
exec: {
output: [ /no results/ ]
},
post: function (output, text) {
ok(!text.includes("index"), "index is not contained in output");
ok(!text.includes("page1"), "page1 is not contained in output");
ok(!text.includes("page2"), "page1 is not contained in output");
ok(!text.includes("page3"), "page1 is not contained in output");
}
},
{
setup: "appcache viewentry --key " + TEST_URI,
check: {
input: "appcache viewentry --key " + TEST_URI,
// appcache viewentry --key http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {}
},
},
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,5 @@
CACHE MANIFEST
browser_cmd_appcache_valid_index.html
browser_cmd_appcache_valid_page1.html
browser_cmd_appcache_valid_page2.html
browser_cmd_appcache_valid_page3.html

View file

@ -0,0 +1,2 @@
Content-Type: text/cache-manifest
Last-Modified: Tue, 23 Apr 9998 11:41:13 GMT

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example index.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page1.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page2.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example page3.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

View file

@ -0,0 +1,119 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the calllog commands works as they should
const TEST_URI = "data:text/html;charset=utf-8,gcli-calllog";
var tests = {};
function test() {
return Task.spawn(function* () {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
yield helpers.runTests(options, tests);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}).then(finish, helpers.handleError);
}
tests.testCallLogStatus = function (options) {
return helpers.audit(options, [
{
setup: "calllog",
check: {
input: "calllog",
hints: "",
markup: "IIIIIII",
status: "ERROR"
}
},
{
setup: "calllog start",
check: {
input: "calllog start",
hints: "",
markup: "VVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "calllog stop",
check: {
input: "calllog stop",
hints: "",
markup: "VVVVVVVVVVVV",
status: "VALID"
}
},
]);
};
tests.testCallLogExec = function (options) {
var deferred = promise.defer();
var onWebConsoleOpen = function (subject) {
Services.obs.removeObserver(onWebConsoleOpen, "web-console-created");
subject.QueryInterface(Ci.nsISupportsString);
let hud = HUDService.getHudReferenceById(subject.data);
ok(hud, "console open");
helpers.audit(options, [
{
setup: "calllog stop",
exec: {
output: /Stopped call logging/,
}
},
{
setup: "console clear",
exec: {
output: "",
},
post: function () {
let labels = hud.outputNode.querySelectorAll(".webconsole-msg-output");
is(labels.length, 0, "no output in console");
}
},
{
setup: "console close",
exec: {
output: "",
}
},
]).then(function () {
deferred.resolve();
});
};
Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false);
helpers.audit(options, [
{
setup: "calllog stop",
exec: {
output: /No call logging/,
}
},
{
name: "calllog start",
setup: function () {
// This test wants to be in a different event
var deferred = promise.defer();
executeSoon(function () {
helpers.setInput(options, "calllog start").then(() => {
deferred.resolve();
});
});
return deferred.promise;
},
exec: {
output: /Call logging started/,
},
},
]);
return deferred.promise;
};

View file

@ -0,0 +1,116 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the calllog commands works as they should
const TEST_URI = "data:text/html;charset=utf-8,cmd-calllog-chrome";
var tests = {};
function test() {
return Task.spawn(function* () {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
yield helpers.runTests(options, tests);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}).then(finish, helpers.handleError);
}
tests.testCallLogStatus = function (options) {
return helpers.audit(options, [
{
setup: "calllog",
check: {
status: "ERROR",
emptyParameters: [ " " ]
}
},
{
setup: "calllog chromestop",
check: {
status: "VALID",
emptyParameters: [ " " ]
}
},
{
setup: "calllog chromestart content-variable window",
check: {
status: "VALID",
emptyParameters: [ " " ]
}
},
{
setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"",
check: {
status: "VALID",
emptyParameters: [ " " ]
}
},
]);
};
tests.testCallLogExec = function (options) {
let deferred = promise.defer();
function onWebConsoleOpen(subject) {
Services.obs.removeObserver(onWebConsoleOpen, "web-console-created");
subject.QueryInterface(Ci.nsISupportsString);
let hud = HUDService.getHudReferenceById(subject.data);
ok(hud, "console open");
helpers.audit(options, [
{
setup: "calllog chromestop",
exec: {
output: /Stopped call logging/,
}
},
{
setup: "calllog chromestart javascript XXX",
exec: {
output: /following exception/,
}
},
{
setup: "console clear",
exec: {
output: "",
},
post: function () {
let labels = hud.jsterm.outputNode.querySelectorAll(".webconsole-msg-output");
is(labels.length, 0, "no output in console");
}
},
{
setup: "console close",
exec: {
output: "",
},
},
]).then(function () {
deferred.resolve();
});
}
Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false);
helpers.audit(options, [
{
setup: "calllog chromestop",
exec: {
output: /No call logging/
}
},
{
setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"",
exec: {
output: /Call logging started/,
}
},
]);
return deferred.promise;
};

View file

@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test various GCLI commands
const TEST_URI = "data:text/html;charset=utf-8,gcli-commands";
const HUDService = require("devtools/client/webconsole/hudservice");
// Use the old webconsole since pprint isn't working on new one (Bug 1304794)
Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false);
registerCleanupFunction(function* () {
Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
});
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
let subjectPromise = helpers.observeOnce("web-console-created");
helpers.audit(options, [
{
setup: "console open",
exec: { }
}
]);
let subject = yield subjectPromise;
subject.QueryInterface(Ci.nsISupportsString);
let hud = HUDService.getHudReferenceById(subject.data);
ok(hud, "console open");
let msg = yield hud.jsterm.execute("pprint(window)");
ok(msg, "output for pprint(window)");
yield helpers.audit(options, [
{
setup: "console clear",
exec: { output: "" }
}
]);
let labels = hud.outputNode.querySelectorAll(".message");
is(labels.length, 0, "no output in console");
yield helpers.audit(options, [
{
setup: "console close",
exec: { output: "" }
}
]);
ok(!HUDService.getHudReferenceById(hud.hudId), "console closed");
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GCLI cookie command test</title>
</head>
<body>
<p>Cookie test</p>
<p id=result></p>
<script type="text/javascript">
document.cookie = "zap=zep";
document.cookie = "zip=zop";
document.cookie = "zig=zag; domain=.mochi.test";
document.getElementById("result").innerHTML = document.cookie;
</script>
</body>
</html>

View file

@ -0,0 +1,170 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the cookie commands works as they should
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_cookie.html";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "cookie",
check: {
input: "cookie",
hints: " list",
markup: "IIIIII",
status: "ERROR"
},
},
{
setup: "cookie lis",
check: {
input: "cookie lis",
hints: "t",
markup: "IIIIIIVIII",
status: "ERROR"
},
},
{
setup: "cookie list",
check: {
input: "cookie list",
hints: "",
markup: "VVVVVVVVVVV",
status: "VALID"
},
},
{
setup: "cookie remove",
check: {
input: "cookie remove",
hints: " <name>",
markup: "VVVVVVVVVVVVV",
status: "ERROR"
},
},
{
setup: "cookie set",
check: {
input: "cookie set",
hints: " <name> <value> [options]",
markup: "VVVVVVVVVV",
status: "ERROR"
},
},
{
setup: "cookie set fruit",
check: {
input: "cookie set fruit",
hints: " <value> [options]",
markup: "VVVVVVVVVVVVVVVV",
status: "ERROR"
},
},
{
setup: "cookie set fruit ban",
check: {
input: "cookie set fruit ban",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
name: { value: "fruit" },
value: { value: "ban" },
secure: { value: false },
}
},
},
{
setup: 'cookie set fruit ban --path ""',
check: {
input: 'cookie set fruit ban --path ""',
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
name: { value: "fruit" },
value: { value: "ban" },
path: { value: "" },
secure: { value: false },
}
},
},
{
setup: "cookie list",
exec: {
output: [ /zap=zep/, /zip=zop/, /Edit/ ]
}
},
{
setup: "cookie set zup banana",
check: {
args: {
name: { value: "zup" },
value: { value: "banana" },
}
},
exec: {
output: ""
}
},
{
setup: "cookie list",
exec: {
output: [ /zap=zep/, /zip=zop/, /zup=banana/, /Edit/ ]
}
},
{
setup: "cookie remove zip",
exec: { },
},
{
setup: "cookie list",
exec: {
output: [ /zap=zep/, /zup=banana/, /Edit/ ]
},
post: function (output, text) {
ok(!text.includes("zip"), "");
ok(!text.includes("zop"), "");
}
},
{
setup: "cookie remove zap",
exec: { },
},
{
setup: "cookie list",
exec: {
output: [ /zup=banana/, /Edit/ ]
},
post: function (output, text) {
ok(!text.includes("zap"), "");
ok(!text.includes("zep"), "");
ok(!text.includes("zip"), "");
ok(!text.includes("zop"), "");
}
},
{
setup: "cookie remove zup",
exec: { }
},
{
setup: "cookie list",
exec: {
output: "No cookies found for host example.com"
},
post: function (output, text) {
ok(!text.includes("zap"), "");
ok(!text.includes("zep"), "");
ok(!text.includes("zip"), "");
ok(!text.includes("zop"), "");
ok(!text.includes("zup"), "");
ok(!text.includes("banana"), "");
ok(!text.includes("Edit"), "");
}
},
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the cookie command works for host with a port specified
const TEST_URI = "http://mochi.test:8888/browser/devtools/client/commandline/" +
"test/browser_cmd_cookie.html";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "cookie list",
exec: {
output: [ /zap=zep/, /zip=zop/, /zig=zag/ ],
}
},
{
setup: "cookie set zup banana",
check: {
args: {
name: { value: "zup" },
value: { value: "banana" },
}
},
exec: {
output: ""
}
},
{
setup: "cookie list",
exec: {
output: [ /zap=zep/, /zip=zop/, /zig=zag/, /zup=banana/, /Edit/ ]
}
}
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,318 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the addon commands works as they should
const csscoverage = require("devtools/shared/fronts/csscoverage");
const PAGE_1 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page1.html";
const PAGE_2 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page2.html";
const PAGE_3 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page3.html";
const SHEET_A = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetA.css";
const SHEET_B = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetB.css";
const SHEET_C = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetC.css";
const SHEET_D = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetD.css";
add_task(function* () {
let options = yield helpers.openTab(PAGE_3);
yield helpers.openToolbar(options);
let usage = yield csscoverage.getUsage(options.target);
yield navigate(usage, options);
yield checkPages(usage);
yield checkEditorReport(usage);
// usage.createPageReport is not supported for usage.oneshot data as of
// bug 1035300 because the page report assumed we have preload data which
// oneshot can't gather. The ideal solution is to have a special no-preload
// mode for the page report, but since oneshot isn't needed for the UI to
// function, we're currently not supporting page report for oneshot data
// yield checkPageReport(usage);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
});
/**
* Just check current page
*/
function* navigate(usage, options) {
ok(!usage.isRunning(), "csscoverage is not running");
yield usage.oneshot();
ok(!usage.isRunning(), "csscoverage is still not running");
}
/**
* Check the expected pages have been visited
*/
function* checkPages(usage) {
let expectedVisited = [ PAGE_3 ];
let actualVisited = yield usage._testOnlyVisitedPages();
isEqualJson(actualVisited, expectedVisited, "Visited");
}
/**
* Check that createEditorReport returns the expected JSON
*/
function* checkEditorReport(usage) {
// Page1
let expectedPage1 = { reports: [] };
let actualPage1 = yield usage.createEditorReport(PAGE_1 + " \u2192 <style> index 0");
isEqualJson(actualPage1, expectedPage1, "Page1");
// Page2
let expectedPage2 = { reports: [] };
let actualPage2 = yield usage.createEditorReport(PAGE_2 + " \u2192 <style> index 0");
isEqualJson(actualPage2, expectedPage2, "Page2");
// Page3a
let expectedPage3a = {
reports: [
{
selectorText: ".page3-test2",
start: { line: 9, column: 5 },
}
]
};
let actualPage3a = yield usage.createEditorReport(PAGE_3 + " \u2192 <style> index 0");
isEqualJson(actualPage3a, expectedPage3a, "Page3a");
// Page3b
let expectedPage3b = {
reports: [
{
selectorText: ".page3-test3",
start: { line: 3, column: 5 },
}
]
};
let actualPage3b = yield usage.createEditorReport(PAGE_3 + " \u2192 <style> index 1");
isEqualJson(actualPage3b, expectedPage3b, "Page3b");
// SheetA
let expectedSheetA = {
reports: [
{
selectorText: ".sheetA-test2",
start: { line: 8, column: 1 },
},
{
selectorText: ".sheetA-test3",
start: { line: 12, column: 1 },
},
{
selectorText: ".sheetA-test4",
start: { line: 16, column: 1 },
}
]
};
let actualSheetA = yield usage.createEditorReport(SHEET_A);
isEqualJson(actualSheetA, expectedSheetA, "SheetA");
// SheetB
let expectedSheetB = {
reports: [
{
selectorText: ".sheetB-test2",
start: { line: 6, column: 1 },
},
{
selectorText: ".sheetB-test3",
start: { line: 10, column: 1 },
},
{
selectorText: ".sheetB-test4",
start: { line: 14, column: 1 },
}
]
};
let actualSheetB = yield usage.createEditorReport(SHEET_B);
isEqualJson(actualSheetB, expectedSheetB, "SheetB");
// SheetC
let expectedSheetC = {
reports: [
{
selectorText: ".sheetC-test2",
start: { line: 6, column: 1 },
},
{
selectorText: ".sheetC-test3",
start: { line: 10, column: 1 },
},
{
selectorText: ".sheetC-test4",
start: { line: 14, column: 1 },
}
]
};
let actualSheetC = yield usage.createEditorReport(SHEET_C);
isEqualJson(actualSheetC, expectedSheetC, "SheetC");
// SheetD
let expectedSheetD = {
reports: [
{
selectorText: ".sheetD-test2",
start: { line: 6, column: 1 },
},
{
selectorText: ".sheetD-test3",
start: { line: 10, column: 1 },
},
{
selectorText: ".sheetD-test4",
start: { line: 14, column: 1 },
}
]
};
let actualSheetD = yield usage.createEditorReport(SHEET_D);
isEqualJson(actualSheetD, expectedSheetD, "SheetD");
}
/**
* Check that checkPageReport returns the expected JSON
*/
function* checkPageReport(usage) {
let actualReport = yield usage.createPageReport();
// Quick check on trivial things. See doc comment for checkRuleProperties
actualReport.preload.forEach(page => page.rules.forEach(checkRuleProperties));
actualReport.unused.forEach(page => page.rules.forEach(checkRuleProperties));
// Check the summary
let expectedSummary = { "used": 23, "unused": 9, "preload": 0 };
isEqualJson(actualReport.summary, expectedSummary, "summary");
// Check the preload header
isEqualJson(actualReport.preload.length, 0, "preload length");
// Check the unused header
isEqualJson(actualReport.unused.length, 6, "unused length");
// Check the unused rules
isEqualJson(actualReport.unused[0].url, PAGE_3 + " \u2192 <style> index 0", "unused url 0");
let expectedUnusedRules0 = [
{
"url": PAGE_3 + " \u2192 <style> index 0",
"start": { "line": 9, "column": 5 },
"selectorText": ".page3-test2"
}
];
isEqualJson(actualReport.unused[0].rules, expectedUnusedRules0, "unused rules 0");
isEqualJson(actualReport.unused[1].url, PAGE_3 + " \u2192 <style> index 1", "unused url 1");
let expectedUnusedRules1 = [
{
"url": PAGE_3 + " \u2192 <style> index 1",
"start": { "line": 3, "column": 5 },
"selectorText": ".page3-test3"
}
];
isEqualJson(actualReport.unused[1].rules, expectedUnusedRules1, "unused rules 1");
isEqualJson(actualReport.unused[2].url, SHEET_A, "unused url 2");
let expectedUnusedRules2 = [
{
"url": SHEET_A,
"start": { "line": 8, "column": 1 },
"selectorText": ".sheetA-test2"
},
{
"url": SHEET_A,
"start": { "line": 12, "column": 1 },
"selectorText": ".sheetA-test3"
},
{
"url": SHEET_A,
"start": { "line": 16, "column": 1 },
"selectorText": ".sheetA-test4"
}
];
isEqualJson(actualReport.unused[2].rules, expectedUnusedRules2, "unused rules 2");
isEqualJson(actualReport.unused[3].url, SHEET_B, "unused url 3");
let expectedUnusedRules3 = [
{
"url": SHEET_B,
"start": { "line": 6, "column": 1 },
"selectorText": ".sheetB-test2"
},
{
"url": SHEET_B,
"start": { "line": 10, "column": 1 },
"selectorText": ".sheetB-test3"
},
{
"url": SHEET_B,
"start": { "line": 14, "column": 1 },
"selectorText": ".sheetB-test4"
}
];
isEqualJson(actualReport.unused[3].rules, expectedUnusedRules3, "unused rules 3");
isEqualJson(actualReport.unused[4].url, SHEET_D, "unused url 4");
let expectedUnusedRules4 = [
{
"url": SHEET_D,
"start": { "line": 6, "column": 1 },
"selectorText": ".sheetD-test2"
},
{
"url": SHEET_D,
"start": { "line": 10, "column": 1 },
"selectorText": ".sheetD-test3"
},
{
"url": SHEET_D,
"start": { "line": 14, "column": 1 },
"selectorText": ".sheetD-test4"
}
];
isEqualJson(actualReport.unused[4].rules, expectedUnusedRules4, "unused rules 4");
isEqualJson(actualReport.unused[5].url, SHEET_C, "unused url 5");
let expectedUnusedRules5 = [
{
"url": SHEET_C,
"start": { "line": 6, "column": 1 },
"selectorText": ".sheetC-test2"
},
{
"url": SHEET_C,
"start": { "line": 10, "column": 1 },
"selectorText": ".sheetC-test3"
},
{
"url": SHEET_C,
"start": { "line": 14, "column": 1 },
"selectorText": ".sheetC-test4"
}
];
isEqualJson(actualReport.unused[5].rules, expectedUnusedRules5, "unused rules 5");
}
/**
* We do basic tests on the shortUrl and formattedCssText because they are
* very derivative, and so make for fragile tests, and having done those quick
* existence checks we remove them so the JSON check later can ignore them
*/
function checkRuleProperties(rule, index) {
is(typeof rule.shortUrl, "string", "typeof rule.shortUrl for " + index);
is(rule.shortUrl.indexOf("http://"), -1, "http not in rule.shortUrl for" + index);
delete rule.shortUrl;
is(typeof rule.formattedCssText, "string", "typeof rule.formattedCssText for " + index);
ok(rule.formattedCssText.indexOf("{") > 0, "{ in rule.formattedCssText for " + index);
delete rule.formattedCssText;
}
/**
* Utility to compare JSON structures
*/
function isEqualJson(o1, o2, msg) {
is(JSON.stringify(o1), JSON.stringify(o2), msg);
}

View file

@ -0,0 +1,85 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<!--
First page of the css coverage test.
* Contains page2 in an iframe
* Forwards to page2 on a timeout
-->
<title>Page 1</title>
<style>
@import url(browser_cmd_csscoverage_sheetD.css);
/* This should match below */
.page1-test1 {
color: #011;
}
/* This should not match below */
.page1-test2 {
color: #012;
}
/* This would match if the mouse was in the right place */
.page1-test3:hover {
color: #013;
}
/* This can't match because it's illegal */
.page1-test4:broken {
color: #014;
}
/* This doesn't match until the event fires */
.page1-test5 {
color: #015;
}
/* TODO: include examples of all CSS rules in
https://developer.mozilla.org/en-US/docs/Web/API/CSSRule
and include tests for rules nested in media rules, etc */
/* We're not testing unparable CSS right now */
</style>
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetA.css">
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetB.css">
<script type="application/javascript;version=1.8">
/* How quickly do we rush through this? */
let delay = 500;
window.addEventListener("load", () => {
dump('TEST-INFO | load from browser_cmd_csscoverage_page1.html\n');
setTimeout(() => {
dump('TEST-INFO | timeout from browser_cmd_csscoverage_page1.html\n');
/* This adds <div class=page1-test5></div> */
let parent = document.querySelector("#page1-test5-holder");
let child = document.createElement("div");
child.classList.add("page1-test5");
parent.appendChild(child);
/* Then navigate to the next step */
window.location.href = "browser_cmd_csscoverage_page3.html"
}, delay);
});
</script>
</head>
<body>
<h2>Page 1</h2>
<div class=page1-test1>.page1-test1</div>
<div class=page1-test3>.page1-test3</div>
<div id=page1-test5-holder></div>
<div class=sheetA-test1>.sheetA-test1</div>
<div class=sheetA-test3>.sheetA-test3</div>
<div class=sheetB-test1>.sheetB-test1</div>
<div class=sheetB-test3>.sheetB-test3</div>
<div class=sheetC-test1>.sheetC-test1</div>
<div class=sheetC-test3>.sheetC-test3</div>
<div class=sheetD-test1>.sheetD-test1</div>
<div class=sheetD-test3>.sheetD-test3</div>
<iframe src=browser_cmd_csscoverage_page2.html></iframe>
<p>
<a href="browser_cmd_csscoverage_page3.html">Page 3</a>
</p>
</body>
</html>

View file

@ -0,0 +1,59 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Page 2</title>
<style>
@import url(browser_cmd_csscoverage_sheetD.css);
/* This should match below */
.page2-test1 {
color: #021;
}
/* This should not match below */
.page2-test2 {
color: #022;
}
/* This doesn't match until the event fires */
.page2-test3 {
color: #023;
}
</style>
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetA.css">
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetB.css">
<script type="application/javascript;version=1.8">
/* How quickly do we rush through this? */
let delay = 500;
window.addEventListener("load", () => {
dump('TEST-INFO | load from browser_cmd_csscoverage_page2.html\n');
setTimeout(() => {
dump('TEST-INFO | timeout from browser_cmd_csscoverage_page2.html\n');
/* This adds <div class=page2-test3></div> */
let parent = document.querySelector("#page2-test3-holder");
let child = document.createElement("div");
child.classList.add("page2-test3");
parent.appendChild(child);
}, delay);
});
</script>
</head>
<body>
<h2>Page 2</h2>
<div class=page2-test1>.page2-test1</div>
<div id=page2-test3-holder></div>
<div class=sheetA-test1>.sheetA-test1</div>
<div class=sheetA-test4>.sheetA-test4</div>
<div class=sheetB-test1>.sheetB-test1</div>
<div class=sheetB-test4>.sheetB-test4</div>
<div class=sheetC-test1>.sheetC-test1</div>
<div class=sheetC-test4>.sheetC-test4</div>
<div class=sheetD-test1>.sheetD-test1</div>
<div class=sheetD-test4>.sheetD-test4</div>
</body>
</html>

View file

@ -0,0 +1,52 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Page 3</title>
<style>
@import url(browser_cmd_csscoverage_sheetD.css);
/* This should match below */
.page3-test1 {
color: #031;
}
/* This should not match below */
.page3-test2 {
color: #032;
}
</style>
<style>
/* This also should not match below, but in a second inline sheet */
.page3-test3 {
color: #033;
}
</style>
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetA.css">
<link rel="stylesheet" type="text/css" href="browser_cmd_csscoverage_sheetB.css">
<script type="application/javascript;version=1.8">
window.addEventListener("load", () => {
dump('TEST-INFO | load from browser_cmd_csscoverage_page3.html\n');
});
</script>
</head>
<body>
<h2>Page 3</h2>
<div class=page3-test1>.page3-test1</div>
<div class=sheetA-test1>.sheetA-test1</div>
<div class=sheetA-test5>.sheetA-test5</div>
<div class=sheetB-test1>.sheetB-test1</div>
<div class=sheetB-test5>.sheetB-test5</div>
<div class=sheetC-test1>.sheetC-test1</div>
<div class=sheetC-test5>.sheetC-test5</div>
<div class=sheetD-test1>.sheetD-test1</div>
<div class=sheetD-test5>.sheetD-test5</div>
<p>
<a href="browser_cmd_csscoverage_page1.html">Page 1</a>
</p>
</body>
</html>

View file

@ -0,0 +1,22 @@
@import url(browser_cmd_csscoverage_sheetC.css);
/* This should match in page 1, 2 and 3 */
.sheetA-test1 {
color: #0A1;
}
/* This should not match anywhere */
.sheetA-test2 {
color: #0A2;
}
/* This should match in page 1 only */
.sheetA-test3 {
color: #0A3;
}
/* This should match in page 2 only */
.sheetA-test4 {
color: #0A4;
}
/* This should match in page 3 only */
.sheetA-test5 {
color: #0A5;
}

View file

@ -0,0 +1,20 @@
/* This should match in page 1, 2 and 3 */
.sheetB-test1 {
color: #0B1;
}
/* This should not match anywhere */
.sheetB-test2 {
color: #0B2;
}
/* This should match in page 1 only */
.sheetB-test3 {
color: #0B3;
}
/* This should match in page 2 only */
.sheetB-test4 {
color: #0B4;
}
/* This should match in page 3 only */
.sheetB-test5 {
color: #0B5;
}

View file

@ -0,0 +1,20 @@
/* This should match in page 1, 2 and 3 */
.sheetC-test1 {
color: #0C1;
}
/* This should not match anywhere */
.sheetC-test2 {
color: #0C2;
}
/* This should match in page 1 only */
.sheetC-test3 {
color: #0C3;
}
/* This should match in page 2 only */
.sheetC-test4 {
color: #0C4;
}
/* This should match in page 3 only */
.sheetC-test5 {
color: #0C5;
}

View file

@ -0,0 +1,20 @@
/* This should match in page 1, 2 and 3 */
.sheetD-test1 {
color: #0D1;
}
/* This should not match anywhere */
.sheetD-test2 {
color: #0D2;
}
/* This should match in page 1 only */
.sheetD-test3 {
color: #0D3;
}
/* This should match in page 2 only */
.sheetD-test4 {
color: #0D4;
}
/* This should match in page 3 only */
.sheetD-test5 {
color: #0D5;
}

View file

@ -0,0 +1,465 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the addon commands works as they should
const csscoverage = require("devtools/shared/fronts/csscoverage");
const PAGE_1 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page1.html";
const PAGE_2 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page2.html";
const PAGE_3 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page3.html";
const SHEET_A = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetA.css";
const SHEET_B = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetB.css";
const SHEET_C = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetC.css";
const SHEET_D = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetD.css";
add_task(function* () {
let options = yield helpers.openTab("about:blank");
yield helpers.openToolbar(options);
let usage = yield csscoverage.getUsage(options.target);
yield navigate(usage, options);
yield checkPages(usage);
yield checkEditorReport(usage);
yield checkPageReport(usage);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
});
/**
* Visit all the pages in the test
*/
function* navigate(usage, options) {
yield usage.start(options.chromeWindow, options.target);
ok(usage.isRunning(), "csscoverage is running");
// Load page 1.
options.browser.loadURI(PAGE_1);
// And wait until page 1 and page 2 (an iframe inside page 1) are both loaded.
yield Promise.all([
BrowserTestUtils.browserLoaded(options.browser, false, PAGE_1),
BrowserTestUtils.browserLoaded(options.browser, true, PAGE_2)
]);
is(options.browser.currentURI.spec, PAGE_1, "page 1 loaded");
// page 2 has JS that navigates to page 3 after a timeout.
yield BrowserTestUtils.browserLoaded(options.browser, false, PAGE_3);
is(options.browser.currentURI.spec, PAGE_3, "page 3 loaded");
let toolboxReady = gDevTools.once("toolbox-ready");
yield usage.stop();
ok(!usage.isRunning(), "csscoverage not is running");
yield toolboxReady;
}
/**
* Check the expected pages have been visited
*/
function* checkPages(usage) {
// 'load' event order. '' is for the initial location
let expectedVisited = [ "", PAGE_2, PAGE_1, PAGE_3 ];
let actualVisited = yield usage._testOnlyVisitedPages();
isEqualJson(actualVisited, expectedVisited, "Visited");
}
/**
* Check that createEditorReport returns the expected JSON
*/
function* checkEditorReport(usage) {
// Page1
let expectedPage1 = {
reports: [
{
selectorText: ".page1-test2",
start: { line: 8, column: 5 },
}
]
};
let actualPage1 = yield usage.createEditorReport(PAGE_1 + " \u2192 <style> index 0");
isEqualJson(actualPage1, expectedPage1, "Page1");
// Page2
let expectedPage2 = {
reports: [
{
selectorText: ".page2-test2",
start: { line: 9, column: 5 },
},
]
};
let actualPage2 = yield usage.createEditorReport(PAGE_2 + " \u2192 <style> index 0");
isEqualJson(actualPage2, expectedPage2, "Page2");
// Page3a
let expectedPage3a = {
reports: [
{
selectorText: ".page3-test2",
start: { line: 9, column: 5 },
}
]
};
let actualPage3a = yield usage.createEditorReport(PAGE_3 + " \u2192 <style> index 0");
isEqualJson(actualPage3a, expectedPage3a, "Page3a");
// Page3b
let expectedPage3b = {
reports: [
{
selectorText: ".page3-test3",
start: { line: 3, column: 5 },
}
]
};
let actualPage3b = yield usage.createEditorReport(PAGE_3 + " \u2192 <style> index 1");
isEqualJson(actualPage3b, expectedPage3b, "Page3b");
// SheetA
let expectedSheetA = {
reports: [
{
selectorText: ".sheetA-test2",
start: { line: 8, column: 1 },
}
]
};
let actualSheetA = yield usage.createEditorReport(SHEET_A);
isEqualJson(actualSheetA, expectedSheetA, "SheetA");
// SheetB
let expectedSheetB = {
reports: [
{
selectorText: ".sheetB-test2",
start: { line: 6, column: 1 },
}
]
};
let actualSheetB = yield usage.createEditorReport(SHEET_B);
isEqualJson(actualSheetB, expectedSheetB, "SheetB");
// SheetC
let expectedSheetC = {
reports: [
{
selectorText: ".sheetC-test2",
start: { line: 6, column: 1 },
}
]
};
let actualSheetC = yield usage.createEditorReport(SHEET_C);
isEqualJson(actualSheetC, expectedSheetC, "SheetC");
// SheetD
let expectedSheetD = {
reports: [
{
selectorText: ".sheetD-test2",
start: { line: 6, column: 1 },
}
]
};
let actualSheetD = yield usage.createEditorReport(SHEET_D);
isEqualJson(actualSheetD, expectedSheetD, "SheetD");
}
/**
* Check that checkPageReport returns the expected JSON
*/
function* checkPageReport(usage) {
let actualReport = yield usage.createPageReport();
// Quick check on trivial things. See doc comment for checkRuleProperties
actualReport.preload.forEach(page => page.rules.forEach(checkRuleProperties));
actualReport.unused.forEach(page => page.rules.forEach(checkRuleProperties));
// Check the summary
let expectedSummary = { "used": 92, "unused": 22, "preload": 28 };
isEqualJson(actualReport.summary, expectedSummary, "summary");
checkPageReportPreload(actualReport);
checkPageReportUnused(actualReport);
}
/**
* Check that checkPageReport returns the expected preload JSON
*/
function checkPageReportPreload(actualReport) {
// Check the preload header
isEqualJson(actualReport.preload.length, 3, "preload length");
// Check the preload rules
isEqualJson(actualReport.preload[0].url, PAGE_2, "preload url 0");
let expectedPreloadRules0 = [
// TODO: This is already pre-loaded, we should note this
{
url: PAGE_2 + " \u2192 <style> index 0",
start: { line: 5, column: 5 },
selectorText: ".page2-test1"
},
{
url: SHEET_A,
start: { line: 4, column: 1 },
selectorText: ".sheetA-test1"
},
{
url: SHEET_A,
start: { line: 16, column: 1 },
selectorText: ".sheetA-test4"
},
{
url: SHEET_B,
start: { line: 2, column: 1 },
selectorText: ".sheetB-test1"
},
{
url: SHEET_B,
start: { line: 14, column: 1 },
selectorText: ".sheetB-test4"
},
{
url: SHEET_D,
start: { line: 2, column: 1 },
selectorText: ".sheetD-test1"
},
{
url: SHEET_D,
start: { line: 14, column: 1 },
selectorText: ".sheetD-test4"
},
{
url: SHEET_C,
start: { line: 2, column: 1 },
selectorText: ".sheetC-test1"
},
{
url: SHEET_C,
start: { line: 14, column: 1 },
selectorText: ".sheetC-test4"
}
];
isEqualJson(actualReport.preload[0].rules, expectedPreloadRules0, "preload rules 0");
isEqualJson(actualReport.preload[1].url, PAGE_1, "preload url 1");
let expectedPreloadRules1 = [
{
url: SHEET_A,
start: { line: 4, column: 1 },
selectorText: ".sheetA-test1"
},
{
url: SHEET_A,
start: { line: 12, column: 1 },
selectorText: ".sheetA-test3"
},
{
url: SHEET_B,
start: { line: 2, column: 1 },
selectorText: ".sheetB-test1"
},
{
url: SHEET_B,
start: { line: 10, column: 1 },
selectorText: ".sheetB-test3"
},
{
url: SHEET_D,
start: { line: 2, column: 1 },
selectorText: ".sheetD-test1"
},
{
url: SHEET_D,
start: { line: 10, column: 1 },
selectorText: ".sheetD-test3"
},
{
url: SHEET_C,
start: { line: 2, column: 1 },
selectorText: ".sheetC-test1"
},
{
url: SHEET_C,
start: { line: 10, column: 1 },
selectorText: ".sheetC-test3"
},
{
url: PAGE_1 + " \u2192 <style> index 0",
start: { line: 4, column: 5 },
selectorText: ".page1-test1"
},
{
url: PAGE_1 + " \u2192 <style> index 0",
start: { line: 12, column: 5 },
selectorText: ".page1-test3:hover"
}
];
isEqualJson(actualReport.preload[1].rules, expectedPreloadRules1, "preload rules 1");
isEqualJson(actualReport.preload[2].url, PAGE_3, "preload url 2");
let expectedPreloadRules2 = [
{
url: SHEET_A,
start: { line: 4, column: 1 },
selectorText: ".sheetA-test1"
},
{
url: SHEET_A,
start: { line: 20, column: 1 },
selectorText: ".sheetA-test5"
},
{
url: SHEET_B,
start: { line: 2, column: 1 },
selectorText: ".sheetB-test1"
},
{
url: SHEET_B,
start: { line: 18, column: 1 },
selectorText: ".sheetB-test5"
},
{
url: SHEET_D,
start: { line: 2, column: 1 },
selectorText: ".sheetD-test1"
},
{
url: SHEET_D,
start: { line: 18, column: 1 },
selectorText: ".sheetD-test5"
},
{
url: SHEET_C,
start: { line: 2, column: 1 },
selectorText: ".sheetC-test1"
},
{
url: SHEET_C,
start: { line: 18, column: 1 },
selectorText: ".sheetC-test5"
},
{
url: PAGE_3 + " \u2192 <style> index 0",
start: { line: 5, column: 5 },
selectorText: ".page3-test1"
},
];
isEqualJson(actualReport.preload[2].rules, expectedPreloadRules2, "preload rules 2");
}
/**
* Check that checkPageReport returns the expected unused JSON
*/
function checkPageReportUnused(actualReport) {
// Check the unused header
isEqualJson(actualReport.unused.length, 8, "unused length");
// Check the unused rules
isEqualJson(actualReport.unused[0].url, PAGE_2 + " \u2192 <style> index 0", "unused url 0");
let expectedUnusedRules0 = [
{
url: PAGE_2 + " \u2192 <style> index 0",
start: { line: 9, column: 5 },
selectorText: ".page2-test2"
}
];
isEqualJson(actualReport.unused[0].rules, expectedUnusedRules0, "unused rules 0");
isEqualJson(actualReport.unused[1].url, SHEET_A, "unused url 1");
let expectedUnusedRules1 = [
{
url: SHEET_A,
start: { line: 8, column: 1 },
selectorText: ".sheetA-test2"
}
];
isEqualJson(actualReport.unused[1].rules, expectedUnusedRules1, "unused rules 1");
isEqualJson(actualReport.unused[2].url, SHEET_B, "unused url 2");
let expectedUnusedRules2 = [
{
url: SHEET_B,
start: { line: 6, column: 1 },
selectorText: ".sheetB-test2"
}
];
isEqualJson(actualReport.unused[2].rules, expectedUnusedRules2, "unused rules 2");
isEqualJson(actualReport.unused[3].url, SHEET_D, "unused url 3");
let expectedUnusedRules3 = [
{
url: SHEET_D,
start: { line: 6, column: 1 },
selectorText: ".sheetD-test2"
}
];
isEqualJson(actualReport.unused[3].rules, expectedUnusedRules3, "unused rules 3");
isEqualJson(actualReport.unused[4].url, SHEET_C, "unused url 4");
let expectedUnusedRules4 = [
{
url: SHEET_C,
start: { line: 6, column: 1 },
selectorText: ".sheetC-test2"
}
];
isEqualJson(actualReport.unused[4].rules, expectedUnusedRules4, "unused rules 4");
isEqualJson(actualReport.unused[5].url, PAGE_1 + " \u2192 <style> index 0", "unused url 5");
let expectedUnusedRules5 = [
{
url: PAGE_1 + " \u2192 <style> index 0",
start: { line: 8, column: 5 },
selectorText: ".page1-test2"
}
];
isEqualJson(actualReport.unused[5].rules, expectedUnusedRules5, "unused rules 5");
isEqualJson(actualReport.unused[6].url, PAGE_3 + " \u2192 <style> index 0", "unused url 6");
let expectedUnusedRules6 = [
{
url: PAGE_3 + " \u2192 <style> index 0",
start: { line: 9, column: 5 },
selectorText: ".page3-test2"
}
];
isEqualJson(actualReport.unused[6].rules, expectedUnusedRules6, "unused rules 6");
isEqualJson(actualReport.unused[7].url, PAGE_3 + " \u2192 <style> index 1", "unused url 7");
let expectedUnusedRules7 = [
{
url: PAGE_3 + " \u2192 <style> index 1",
start: { line: 3, column: 5 },
selectorText: ".page3-test3"
}
];
isEqualJson(actualReport.unused[7].rules, expectedUnusedRules7, "unused rules 7");
}
/**
* We do basic tests on the shortUrl and formattedCssText because they are
* very derivative, and so make for fragile tests, and having done those quick
* existence checks we remove them so the JSON check later can ignore them
*/
function checkRuleProperties(rule, index) {
is(typeof rule.shortUrl, "string", "typeof rule.shortUrl for " + index);
is(rule.shortUrl.indexOf("http://"), -1, "http not in rule.shortUrl for" + index);
delete rule.shortUrl;
is(typeof rule.formattedCssText, "string", "typeof rule.formattedCssText for " + index);
ok(rule.formattedCssText.indexOf("{") > 0, "{ in rule.formattedCssText for " + index);
delete rule.formattedCssText;
}
/**
* Utility to compare JSON structures
*/
function isEqualJson(o1, o2, msg) {
is(JSON.stringify(o1), JSON.stringify(o2), msg);
}

View file

@ -0,0 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the addon commands works as they should
const csscoverage = require("devtools/server/actors/csscoverage");
add_task(function* () {
testDeconstructRuleId();
});
function testDeconstructRuleId() {
// This is the easy case
let rule = csscoverage.deconstructRuleId("http://thing/blah|10|20");
is(rule.url, "http://thing/blah", "1 url");
is(rule.line, 10, "1 line");
is(rule.column, 20, "1 column");
// This is the harder case with a URL containing a '|'
rule = csscoverage.deconstructRuleId("http://thing/blah?q=a|b|11|22");
is(rule.url, "http://thing/blah?q=a|b", "2 url");
is(rule.line, 11, "2 line");
is(rule.column, 22, "2 column");
}

View file

@ -0,0 +1,58 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the folder commands works as they should
const TEST_URI = "data:text/html;charset=utf-8,cmd-folder";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "folder",
check: {
input: "folder",
hints: " open",
markup: "IIIIII",
status: "ERROR"
},
},
{
setup: "folder open",
check: {
input: "folder open",
hints: " [path]",
markup: "VVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "folder open ~",
check: {
input: "folder open ~",
hints: "",
markup: "VVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "folder openprofile",
check: {
input: "folder openprofile",
hints: "",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "folder openprofile WRONG",
check: {
input: "folder openprofile WRONG",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVEEEEE",
status: "ERROR"
}
}
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,90 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* eslint key-spacing: 0 */
// Tests the various highlight command parameters and options
// Creating a test page with many elements to test the --showall option
var TEST_PAGE = "data:text/html;charset=utf-8,<body><ul>";
for (let i = 0; i < 101; i++) {
TEST_PAGE += "<li class='item'>" + i + "</li>";
}
TEST_PAGE += "</ul></body>";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "highlight",
check: {
input: "highlight",
hints: " [selector] [options]",
markup: "VVVVVVVVV",
status: "VALID"
},
exec: {
output: "0 nodes highlighted"
}
},
{
setup: "highlight bo",
check: {
input: "highlight bo",
hints: " [options]",
markup: "VVVVVVVVVVII",
status: "ERROR"
},
exec: {
output: "Error: No matches"
}
},
{
setup: "highlight body",
check: {
input: "highlight body",
hints: " [options]",
markup: "VVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
},
{
setup: "highlight body --hideguides",
check: {
input: "highlight body --hideguides",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
},
{
setup: "highlight body --showinfobar",
check: {
input: "highlight body --showinfobar",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,45 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the highlight command actually creates a highlighter
const TEST_PAGE = "data:text/html;charset=utf-8,<div></div>";
function test() {
return Task.spawn(function* () {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
info("highlighting the body node");
yield runCommand("highlight body", options);
is(yield getHighlighterNumber(), 1, "The highlighter element exists for body");
info("highlighting the div node");
yield runCommand("highlight div", options);
is(yield getHighlighterNumber(), 1, "The highlighter element exists for div");
info("highlighting the body node again, asking to keep the div");
yield runCommand("highlight body --keep", options);
is(yield getHighlighterNumber(), 2, "2 highlighter elements have been created");
info("unhighlighting all nodes");
yield runCommand("unhighlight", options);
is(yield getHighlighterNumber(), 0, "All highlighters have been removed");
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}).then(finish, helpers.handleError);
}
function getHighlighterNumber() {
return ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
return require("devtools/shared/gcli/commands/highlight").highlighters.length;
});
}
function* runCommand(cmd, options) {
yield helpers.audit(options, [{ setup: cmd, exec: {} }]);
}

View file

@ -0,0 +1,131 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* eslint key-spacing: 0 */
// Tests the various highlight command parameters and options that doesn't
// involve nodes at all.
var TEST_PAGE = "data:text/html;charset=utf-8,";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "highlight body --hide",
check: {
input: "highlight body --hide",
hints: "guides [options]",
markup: "VVVVVVVVVVVVVVVIIIIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "highlight body --show",
check: {
input: "highlight body --show",
hints: "infobar [options]",
markup: "VVVVVVVVVVVVVVVIIIIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "highlight body --showa",
check: {
input: "highlight body --showa",
hints: "ll [options]",
markup: "VVVVVVVVVVVVVVVIIIIIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "highlight body --r",
check: {
input: "highlight body --r",
hints: "egion [options]",
markup: "VVVVVVVVVVVVVVVIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "highlight body --region",
check: {
input: "highlight body --region",
hints: " <selection> [options]",
markup: "VVVVVVVVVVVVVVVIIIIIIII",
status: "ERROR"
},
exec: {
output: "Error: Value required for \u2018region\u2019."
}
},
{
setup: "highlight body --fi",
check: {
input: "highlight body --fi",
hints: "ll [options]",
markup: "VVVVVVVVVVVVVVVIIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "highlight body --fill",
check: {
input: "highlight body --fill",
hints: " <string> [options]",
markup: "VVVVVVVVVVVVVVVIIIIII",
status: "ERROR"
},
exec: {
output: "Error: Value required for \u2018fill\u2019."
}
},
{
setup: "highlight body --ke",
check: {
input: "highlight body --ke",
hints: "ep [options]",
markup: "VVVVVVVVVVVVVVVIIII",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "unhighlight",
check: {
input: "unhighlight",
hints: "",
markup: "VVVVVVVVVVV",
status: "VALID"
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,94 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* eslint key-spacing: 0 */
// Tests the various highlight command parameters and options
// Creating a test page with many elements to test the --showall option
var TEST_PAGE = "data:text/html;charset=utf-8,<body><ul>";
for (let i = 0; i < 101; i++) {
TEST_PAGE += "<li class='item'>" + i + "</li>";
}
TEST_PAGE += "</ul></body>";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "highlight body --showall",
check: {
input: "highlight body --showall",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
},
{
setup: "highlight body --keep",
check: {
input: "highlight body --keep",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
},
{
setup: "highlight body --hideguides --showinfobar --showall --region " +
"content --fill red --keep",
check: {
input: "highlight body --hideguides --showinfobar --showall --region " +
"content --fill red --keep",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" +
"VVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "1 node highlighted"
}
},
{
setup: "highlight .item",
check: {
input: "highlight .item",
hints: " [options]",
markup: "VVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "101 nodes matched, but only 100 nodes highlighted. Use " +
"\u2018--showall\u2019 to show all"
}
},
{
setup: "highlight .item --showall",
check: {
input: "highlight .item --showall",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
exec: {
output: "101 nodes highlighted"
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<head>
<body>
</body>
</html>

View file

@ -0,0 +1,69 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the inject commands works as they should
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_inject.html";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "inject",
check: {
input: "inject",
markup: "VVVVVV",
hints: " <library>",
status: "ERROR"
},
},
{
setup: "inject j",
check: {
input: "inject j",
markup: "VVVVVVVI",
hints: "Query",
status: "ERROR"
},
},
{
setup: "inject notauri",
check: {
input: "inject notauri",
hints: " -> http://notauri/",
markup: "VVVVVVVIIIIIII",
status: "ERROR",
args: {
library: {
value: undefined,
status: "INCOMPLETE"
}
}
}
},
{
setup: "inject http://example.com/browser/devtools/client/commandline/test/browser_cmd_inject.js",
check: {
input: "inject http://example.com/browser/devtools/client/commandline/test/browser_cmd_inject.js",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
hints: "",
status: "VALID",
args: {
library: {
value: function (library) {
is(library.type, "url", "inject type name");
is(library.url.origin, "http://example.com", "inject url hostname");
ok(library.url.pathname.indexOf("_inject.js") != -1, "inject url path");
},
status: "VALID"
}
}
},
exec: {
output: [ /http:\/\/example.com\/browser\/devtools\/client\/commandline\/test\/browser_cmd_inject.js loaded/ ]
}
}
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,103 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the jsb command works as it should
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_jsb_script.jsi";
function test() {
return Task.spawn(testTask).then(finish, helpers.handleError);
}
function* testTask() {
let options = yield helpers.openTab("about:blank");
yield helpers.openToolbar(options);
let notifyPromise = wwNotifyOnce();
helpers.audit(options, [
{
setup: "jsb",
check: {
input: "jsb",
hints: " <url> [options]",
markup: "VVV",
status: "ERROR"
}
},
{
setup: "jsb " + TEST_URI,
// Should result in a new scratchpad window
exec: {
output: "",
error: false
}
}
]);
let { subject } = yield notifyPromise;
let scratchpadWin = subject.QueryInterface(Ci.nsIDOMWindow);
yield helpers.listenOnce(scratchpadWin, "load");
let scratchpad = scratchpadWin.Scratchpad;
yield observeOnce(scratchpad);
let result = scratchpad.getText();
result = result.replace(/[\r\n]]*/g, "\n");
let correct = "function somefunc() {\n" +
" if (true) // Some comment\n" +
" doSomething();\n" +
" for (let n = 0; n < 500; n++) {\n" +
" if (n % 2 == 1) {\n" +
" console.log(n);\n" +
" console.log(n + 1);\n" +
" }\n" +
" }\n" +
"}";
is(result, correct, "JS has been correctly prettified");
if (scratchpadWin) {
scratchpadWin.close();
scratchpadWin = null;
}
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}
/**
* A wrapper for calling Services.ww.[un]registerNotification using promises.
* @return a promise that resolves when the notification service first notifies
* with topic == "domwindowopened".
* The value of the promise is { subject: subject, topic: topic, data: data }
*/
function wwNotifyOnce() {
return new Promise(resolve => {
let onNotify = (subject, topic, data) => {
if (topic == "domwindowopened") {
Services.ww.unregisterNotification(onNotify);
resolve({ subject: subject, topic: topic, data: data });
}
};
Services.ww.registerNotification(onNotify);
});
}
/**
* YET ANOTHER WRAPPER for a place where we are using events as poor-man's
* promises. Perhaps this should be promoted to scratchpad?
*/
function observeOnce(scratchpad) {
return new Promise(resolve => {
let observer = {
onReady: function () {
scratchpad.removeObserver(observer);
resolve();
},
};
scratchpad.addObserver(observer);
});
}

View file

@ -0,0 +1,2 @@
function somefunc(){if (true) // Some comment
doSomething();for(let n=0;n<500;n++){if(n%2==1){console.log(n);console.log(n+1);}}}

View file

@ -0,0 +1,80 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the listen/unlisten commands work as they should.
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_cookie.html";
function test() {
return Task.spawn(testTask).then(finish, helpers.handleError);
}
var tests = {
testInput: function (options) {
return helpers.audit(options, [
{
setup: "listen",
check: {
input: "listen",
markup: "VVVVVV",
status: "VALID"
},
},
{
setup: "unlisten",
check: {
input: "unlisten",
markup: "VVVVVVVV",
status: "VALID"
},
exec: {
output: "All TCP ports closed"
}
},
{
setup: function () {
return helpers.setInput(options, "listen");
},
check: {
input: "listen",
hints: " [port] [protocol]",
markup: "VVVVVV",
status: "VALID"
},
exec: {
output: "Listening on port " + Services.prefs
.getIntPref("devtools.debugger.remote-port")
}
},
{
setup: function () {
return helpers.setInput(options, "listen 8000");
},
exec: {
output: "Listening on port 8000"
}
},
{
setup: function () {
return helpers.setInput(options, "unlisten");
},
exec: {
output: "All TCP ports closed"
}
}
]);
},
};
function* testTask() {
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
yield helpers.runTests(options, tests);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
Services.prefs.clearUserPref("devtools.debugger.remote-enabled");
}

View file

@ -0,0 +1,53 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests the highlight command, ensure no invalid arguments are given
const TEST_PAGE = "data:text/html;charset=utf-8,foo";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "measure",
check: {
input: "measure",
markup: "VVVVVVV",
status: "VALID"
}
},
{
setup: "measure on",
check: {
input: "measure on",
markup: "VVVVVVVVEE",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "measure --visible",
check: {
input: "measure --visible",
markup: "VVVVVVVVEEEEEEEEE",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>GCLI Test for Bug 819930</title>
<style>
@media braille {
body {
background-color: yellow;
}
}
@media embossed {
body {
background-color: indigo;
}
}
@media screen {
body {
background-color: white;
}
}
</style>
</head>
<body>
</body>
</html>

View file

@ -0,0 +1,88 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that screenshot command works properly
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_media.html";
var tests = {
testInput: function (options) {
return helpers.audit(options, [
{
setup: "media emulate braille",
check: {
input: "media emulate braille",
markup: "VVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
type: { value: "braille"},
}
},
},
{
setup: "media reset",
check: {
input: "media reset",
markup: "VVVVVVVVVVV",
status: "VALID",
args: {
}
},
},
]);
},
testEmulateMedia: function (options) {
return helpers.audit(options, [
{
setup: "media emulate braille",
check: {
args: {
type: { value: "braille"}
}
},
exec: {
output: ""
},
post: Task.async(function* () {
yield ContentTask.spawn(options.browser, {}, function* () {
let color = content.getComputedStyle(content.document.body).backgroundColor;
is(color, "rgb(255, 255, 0)", "media correctly emulated");
});
})
}
]);
},
testEndMediaEmulation: function (options) {
return helpers.audit(options, [
{
setup: function () {
let mDV = options.browser.markupDocumentViewer;
mDV.emulateMedium("embossed");
return helpers.setInput(options, "media reset");
},
exec: {
output: ""
},
post: Task.async(function* () {
yield ContentTask.spawn(options.browser, {}, function* () {
let color = content.getComputedStyle(content.document.body).backgroundColor;
is(color, "rgb(255, 255, 255)", "media reset");
});
})
}
]);
}
};
function test() {
return Task.spawn(function* () {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
yield helpers.runTests(options, tests);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GCLI inspect command test</title>
</head>
<body>
<!-- This is a list of 0 h1 elements -->
<!-- This is a list of 1 div elements -->
<div>Hello, I'm a div</div>
<!-- This is a list of 2 span elements -->
<span>Hello, I'm a span</span>
<span>And me</span>
<!-- This is a collection of various things that match only once -->
<p class="someclass">.someclass</p>
<p id="someid">#someid</p>
<button disabled>button[disabled]</button>
<p><strong>p&gt;strong</strong></p>
</body>
</html>

View file

@ -0,0 +1,417 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the inspect command works as it should
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_pagemod_export.html";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
function getHTML() {
return ContentTask.spawn(options.browser, {}, function* () {
return content.document.documentElement.innerHTML;
});
}
const initialHtml = yield getHTML();
function resetContent() {
return ContentTask.spawn(options.browser, initialHtml, function* (html) {
content.document.documentElement.innerHTML = html;
});
}
// Test exporting HTML
yield ContentTask.spawn(options.browser, {}, function* () {
content.wrappedJSObject.oldOpen = content.open;
content.wrappedJSObject.openURL = "";
content.wrappedJSObject.open = function (url) {
// The URL is a data: URL that contains the document source
content.wrappedJSObject.openURL = decodeURIComponent(url);
};
});
yield helpers.audit(options, [
{
setup: "export html",
skipIf: true,
check: {
input: "export html",
hints: " [destination]",
markup: "VVVVVVVVVVV",
status: "VALID",
},
exec: {
output: ""
},
post: Task.async(function* () {
yield ContentTask.spawn(options.browser, {}, function* () {
let openURL = content.wrappedJSObject.openURL;
isnot(openURL.indexOf('<html lang="en">'), -1, "export html works: <html>");
isnot(openURL.indexOf("<title>GCLI"), -1, "export html works: <title>");
isnot(openURL.indexOf('<p id="someid">#'), -1, "export html works: <p>");
});
})
},
{
setup: "export html stdout",
check: {
input: "export html stdout",
hints: "",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
destination: { value: "stdout" }
},
},
exec: {
output: [
/<html lang="en">/,
/<title>GCLI/,
/<p id="someid">#/
]
}
}
]);
yield ContentTask.spawn(options.browser, {}, function* () {
content.wrappedJSObject.open = content.wrappedJSObject.oldOpen;
delete content.wrappedJSObject.openURL;
delete content.wrappedJSObject.oldOpen;
});
// Test 'pagemod replace'
yield helpers.audit(options, [
{
setup: "pagemod replace",
check: {
input: "pagemod replace",
hints: " <search> <replace> [ignoreCase] [selector] [root] [attrOnly] [contentOnly] [attributes]",
markup: "VVVVVVVVVVVVVVV",
status: "ERROR"
}
},
{
setup: "pagemod replace some foo",
check: {
input: "pagemod replace some foo",
hints: " [ignoreCase] [selector] [root] [attrOnly] [contentOnly] [attributes]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "pagemod replace some foo true",
check: {
input: "pagemod replace some foo true",
hints: " [selector] [root] [attrOnly] [contentOnly] [attributes]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "pagemod replace some foo true --attrOnly",
check: {
input: "pagemod replace some foo true --attrOnly",
hints: " [selector] [root] [contentOnly] [attributes]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
}
},
{
setup: "pagemod replace sOme foOBar",
exec: {
output: /^[^:]+: 13\. [^:]+: 0\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "no change in the page");
})
},
{
setup: "pagemod replace sOme foOBar true",
exec: {
output: /^[^:]+: 13\. [^:]+: 2\. [^:]+: 2\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
isnot(html.indexOf('<p class="foOBarclass">.foOBarclass'), -1,
".someclass changed to .foOBarclass");
isnot(html.indexOf('<p id="foOBarid">#foOBarid'), -1,
"#someid changed to #foOBarid");
yield resetContent();
})
},
{
setup: "pagemod replace some foobar --contentOnly",
exec: {
output: /^[^:]+: 13\. [^:]+: 2\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
isnot(html.indexOf('<p class="someclass">.foobarclass'), -1,
".someclass changed to .foobarclass (content only)");
isnot(html.indexOf('<p id="someid">#foobarid'), -1,
"#someid changed to #foobarid (content only)");
yield resetContent();
})
},
{
setup: "pagemod replace some foobar --attrOnly",
exec: {
output: /^[^:]+: 13\. [^:]+: 0\. [^:]+: 2\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
isnot(html.indexOf('<p class="foobarclass">.someclass'), -1,
".someclass changed to .foobarclass (attr only)");
isnot(html.indexOf('<p id="foobarid">#someid'), -1,
"#someid changed to #foobarid (attr only)");
yield resetContent();
})
},
{
setup: "pagemod replace some foobar --root head",
exec: {
output: /^[^:]+: 2\. [^:]+: 0\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed");
})
},
{
setup: "pagemod replace some foobar --selector .someclass,div,span",
exec: {
output: /^[^:]+: 4\. [^:]+: 1\. [^:]+: 1\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
isnot(html.indexOf('<p class="foobarclass">.foobarclass'), -1,
".someclass changed to .foobarclass");
isnot(html.indexOf('<p id="someid">#someid'), -1,
"#someid did not change");
yield resetContent();
})
},
]);
// Test 'pagemod remove element'
yield helpers.audit(options, [
{
setup: "pagemod remove",
check: {
input: "pagemod remove",
hints: " attribute",
markup: "IIIIIIIVIIIIII",
status: "ERROR"
},
},
{
setup: "pagemod remove element",
check: {
input: "pagemod remove element",
hints: " <search> [root] [stripOnly] [ifEmptyOnly]",
markup: "VVVVVVVVVVVVVVVVVVVVVV",
status: "ERROR"
},
},
{
setup: "pagemod remove element foo",
check: {
input: "pagemod remove element foo",
hints: " [root] [stripOnly] [ifEmptyOnly]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
},
{
setup: "pagemod remove element p",
exec: {
output: /^[^:]+: 3\. [^:]+: 3\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html.indexOf('<p class="someclass">'), -1, "p.someclass removed");
is(html.indexOf('<p id="someid">'), -1, "p#someid removed");
is(html.indexOf("<p><strong>"), -1, "<p> wrapping <strong> removed");
isnot(html.indexOf("<span>"), -1, "<span> not removed");
yield resetContent();
})
},
{
setup: "pagemod remove element p head",
exec: {
output: /^[^:]+: 0\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed in the page");
})
},
{
setup: "pagemod remove element p --ifEmptyOnly",
exec: {
output: /^[^:]+: 3\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed in the page");
})
},
{
setup: "pagemod remove element meta,title --ifEmptyOnly",
exec: {
output: /^[^:]+: 2\. [^:]+: 1\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html.indexOf("<meta charset="), -1, "<meta> removed");
isnot(html.indexOf("<title>"), -1, "<title> not removed");
yield resetContent();
})
},
{
setup: "pagemod remove element p --stripOnly",
exec: {
output: /^[^:]+: 3\. [^:]+: 3\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html.indexOf('<p class="someclass">'), -1, "p.someclass removed");
is(html.indexOf('<p id="someid">'), -1, "p#someid removed");
is(html.indexOf("<p><strong>"), -1, "<p> wrapping <strong> removed");
isnot(html.indexOf(".someclass"), -1, ".someclass still exists");
isnot(html.indexOf("#someid"), -1, "#someid still exists");
isnot(html.indexOf("<strong>p"), -1, "<strong> still exists");
yield resetContent();
})
},
]);
// Test 'pagemod remove attribute'
yield helpers.audit(options, [
{
setup: "pagemod remove attribute",
check: {
input: "pagemod remove attribute",
hints: " <searchAttributes> <searchElements> [root] [ignoreCase]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
status: "ERROR",
args: {
searchAttributes: { value: undefined, status: "INCOMPLETE" },
searchElements: { value: undefined, status: "INCOMPLETE" },
// root: { value: undefined }, // 'root' is a node which is remote
// so we can't see the value in tests
ignoreCase: { value: false },
}
},
},
{
setup: "pagemod remove attribute foo bar",
check: {
input: "pagemod remove attribute foo bar",
hints: " [root] [ignoreCase]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
searchAttributes: { value: "foo" },
searchElements: { value: "bar" },
// root: { value: undefined }, // 'root' is a node which is remote
// so we can't see the value in tests
ignoreCase: { value: false },
}
},
post: function () {
return new Promise(resolve => {
executeSoon(resolve);
});
}
},
{
setup: "pagemod remove attribute foo bar",
exec: {
output: /^[^:]+: 0\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed in the page");
})
},
{
setup: "pagemod remove attribute foo p",
exec: {
output: /^[^:]+: 3\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed in the page");
})
},
{
setup: "pagemod remove attribute id p,span",
exec: {
output: /^[^:]+: 5\. [^:]+: 1\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html.indexOf('<p id="someid">#someid'), -1, "p#someid attribute removed");
isnot(html.indexOf("<p>#someid"), -1, "p with someid content still exists");
yield resetContent();
})
},
{
setup: "pagemod remove attribute Class p",
exec: {
output: /^[^:]+: 3\. [^:]+: 0\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html, initialHtml, "nothing changed in the page");
})
},
{
setup: "pagemod remove attribute Class p --ignoreCase",
exec: {
output: /^[^:]+: 3\. [^:]+: 1\.\s*$/
},
post: Task.async(function* () {
let html = yield getHTML();
is(html.indexOf('<p class="someclass">.someclass'), -1,
"p.someclass attribute removed");
isnot(html.indexOf("<p>.someclass"), -1,
"p with someclass content still exists");
yield resetContent();
})
},
]);
// Shutdown
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,60 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the paintflashing command correctly sets its state.
"use strict";
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_cookie.html";
function test() {
return Task.spawn(testTask).then(finish, helpers.handleError);
}
var tests = {
testInput: function (options) {
let toggleCommand = options.requisition.system.commands.get("paintflashing toggle");
let _tab = options.tab;
let actions = [
{
command: "paintflashing on",
isChecked: true,
label: "checked after on"
},
{
command: "paintflashing off",
isChecked: false,
label: "unchecked after off"
},
{
command: "paintflashing toggle",
isChecked: true,
label: "checked after toggle"
},
{
command: "paintflashing toggle",
isChecked: false,
label: "unchecked after toggle"
}
];
return helpers.audit(options, actions.map(spec => ({
setup: spec.command,
exec: {},
post: () => is(toggleCommand.state.isChecked({_tab}), spec.isChecked, spec.label)
})));
},
};
function* testTask() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
yield helpers.runTests(options, tests);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,154 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the pref commands work
var prefBranch = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService).getBranch(null)
.QueryInterface(Ci.nsIPrefBranch2);
const TEST_URI = "data:text/html;charset=utf-8,gcli-pref1";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
let netmonEnabledOrig = prefBranch.getBoolPref("devtools.netmonitor.enabled");
info("originally: devtools.netmonitor.enabled = " + netmonEnabledOrig);
yield helpers.audit(options, [
{
setup: "pref",
check: {
input: "pref",
hints: " reset",
markup: "IIII",
status: "ERROR"
},
},
{
setup: "pref s",
check: {
input: "pref s",
hints: "et",
markup: "IIIIVI",
status: "ERROR"
},
},
{
setup: "pref sh",
check: {
input: "pref sh",
hints: "ow",
markup: "IIIIVII",
status: "ERROR"
},
},
{
setup: "pref show ",
check: {
input: "pref show ",
markup: "VVVVVVVVVV",
status: "ERROR"
},
},
{
setup: "pref show usetexttospeech",
check: {
input: "pref show usetexttospeech",
hints: " -> accessibility.usetexttospeech",
markup: "VVVVVVVVVVIIIIIIIIIIIIIII",
status: "ERROR"
},
},
{
setup: "pref show devtools.netmoni",
check: {
input: "pref show devtools.netmoni",
hints: "tor.enabled",
markup: "VVVVVVVVVVIIIIIIIIIIIIIIII",
status: "ERROR",
tooltipState: "true:importantFieldFlag",
args: {
setting: { value: undefined, status: "INCOMPLETE" },
}
},
},
{
setup: "pref reset devtools.netmonitor.enabled",
check: {
input: "pref reset devtools.netmonitor.enabled",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID"
},
},
{
setup: "pref show devtools.netmonitor.enabled 4",
check: {
input: "pref show devtools.netmonitor.enabled 4",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVE",
status: "ERROR"
},
},
{
setup: "pref set devtools.netmonitor.enabled 4",
check: {
input: "pref set devtools.netmonitor.enabled 4",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVE",
status: "ERROR",
args: {
setting: { arg: " devtools.netmonitor.enabled" },
value: { status: "ERROR", message: "Can\u2019t use \u20184\u2019." },
}
},
},
{
setup: "pref set devtools.editor.tabsize 4",
check: {
input: "pref set devtools.editor.tabsize 4",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
setting: { arg: " devtools.editor.tabsize" },
value: { value: 4 },
}
},
},
{
setup: "pref list",
check: {
input: "pref list",
hints: " -> pref set",
markup: "IIIIVIIII",
status: "ERROR"
},
},
{
setup: "pref show devtools.netmonitor.enabled",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.netmonitor.enabled")
}
},
},
exec: {
output: "devtools.netmonitor.enabled: " + netmonEnabledOrig,
},
post: function () {
prefBranch.setBoolPref("devtools.netmonitor.enabled", netmonEnabledOrig);
}
},
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,105 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the pref commands work
var prefBranch = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService).getBranch(null)
.QueryInterface(Ci.nsIPrefBranch2);
const TEST_URI = "data:text/html;charset=utf-8,gcli-pref2";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
let tabSizeOrig = prefBranch.getIntPref("devtools.editor.tabsize");
info("originally: devtools.editor.tabsize = " + tabSizeOrig);
yield helpers.audit(options, [
{
setup: "pref show devtools.editor.tabsize",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.editor.tabsize")
}
},
},
exec: {
output: "devtools.editor.tabsize: " + tabSizeOrig,
},
},
{
setup: "pref set devtools.editor.tabsize 20",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.editor.tabsize")
},
value: { value: 20 }
},
},
exec: {
output: "",
},
post: function () {
is(prefBranch.getIntPref("devtools.editor.tabsize"), 20,
"devtools.editor.tabsize is 20");
}
},
{
setup: "pref show devtools.editor.tabsize",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.editor.tabsize")
}
},
},
exec: {
output: "devtools.editor.tabsize: 20",
}
},
{
setup: "pref set devtools.editor.tabsize 1",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.editor.tabsize")
},
value: { value: 1 }
},
},
exec: {
output: "",
},
},
{
setup: "pref show devtools.editor.tabsize",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.editor.tabsize")
}
},
},
exec: {
output: "devtools.editor.tabsize: 1",
},
post: function () {
is(prefBranch.getIntPref("devtools.editor.tabsize"), 1,
"devtools.editor.tabsize is 1");
}
},
]);
prefBranch.setIntPref("devtools.editor.tabsize", tabSizeOrig);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,113 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the pref commands work
var prefBranch = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService).getBranch(null)
.QueryInterface(Ci.nsIPrefBranch2);
var supportsString = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_URI);
yield helpers.openToolbar(options);
let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host",
Ci.nsISupportsString).data;
info("originally: devtools.debugger.remote-host = " + remoteHostOrig);
yield helpers.audit(options, [
{
setup: "pref show devtools.debugger.remote-host",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.debugger.remote-host")
}
},
},
exec: {
output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"),
},
},
{
setup: "pref set devtools.debugger.remote-host e.com",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.debugger.remote-host")
},
value: { value: "e.com" }
},
},
exec: {
output: "",
},
},
{
setup: "pref show devtools.debugger.remote-host",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.debugger.remote-host")
}
},
},
exec: {
output: new RegExp("^devtools\.debugger\.remote-host: e.com$"),
},
post: function () {
var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host",
Ci.nsISupportsString).data;
is(ecom, "e.com", "devtools.debugger.remote-host is e.com");
}
},
{
setup: "pref set devtools.debugger.remote-host moz.foo",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.debugger.remote-host")
},
value: { value: "moz.foo" }
},
},
exec: {
output: "",
},
},
{
setup: "pref show devtools.debugger.remote-host",
check: {
args: {
setting: {
value: options.requisition.system.settings.get("devtools.debugger.remote-host")
}
},
},
exec: {
output: new RegExp("^devtools\.debugger\.remote-host: moz.foo$"),
},
post: function () {
var mozfoo = prefBranch.getComplexValue("devtools.debugger.remote-host",
Ci.nsISupportsString).data;
is(mozfoo, "moz.foo", "devtools.debugger.remote-host is moz.foo");
}
},
]);
supportsString.data = remoteHostOrig;
prefBranch.setComplexValue("devtools.debugger.remote-host",
Ci.nsISupportsString, supportsString);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,33 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the qsa commands work as they should.
const TEST_URI = "data:text/html;charset=utf-8,<body></body>";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "qsa",
check: {
input: "qsa",
hints: " [query]",
markup: "VVV",
status: "VALID"
}
},
{
setup: "qsa body",
check: {
input: "qsa body",
hints: "",
markup: "VVVVVVVV",
status: "VALID"
}
}
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that restart command works properly (input wise)
const TEST_URI = "data:text/html;charset=utf-8,gcli-command-restart";
function test() {
helpers.addTabWithToolbar(TEST_URI, function (options) {
return helpers.audit(options, [
{
setup: "restart",
check: {
input: "restart",
markup: "VVVVVVV",
status: "VALID",
args: {
nocache: { value: false },
safemode: { value: false },
}
},
},
{
setup: "restart --nocache",
check: {
input: "restart --nocache",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
nocache: { value: true },
safemode: { value: false },
}
},
},
{
setup: "restart --safemode",
check: {
input: "restart --safemode",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
nocache: { value: false },
safemode: { value: true },
}
},
},
{
setup: "restart --safemode --nocache",
check: {
input: "restart --safemode --nocache",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
nocache: { value: true },
safemode: { value: true },
}
},
},
]);
}).then(finish, helpers.handleError);
}

View file

@ -0,0 +1,53 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests the various highlight command parameters and options
var TEST_PAGE = "data:text/html;charset=utf-8,foo";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
let options = yield helpers.openTab(TEST_PAGE);
yield helpers.openToolbar(options);
yield helpers.audit(options, [
{
setup: "rulers",
check: {
input: "rulers",
markup: "VVVVVV",
status: "VALID"
}
},
{
setup: "rulers on",
check: {
input: "rulers on",
markup: "VVVVVVVEE",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
},
{
setup: "rulers --visible",
check: {
input: "rulers --visible",
markup: "VVVVVVVEEEEEEEEE",
status: "ERROR"
},
exec: {
output: "Error: Too many arguments"
}
}
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,18 @@
<html>
<head>
<style>
img {
height: 100px;
width: 100px;
}
.overflow {
overflow: scroll;
height: 200%;
width: 200%;
}
</style>
</head>
<body>
<img id="testImage" ></img>
</body>
</html>

View file

@ -0,0 +1,374 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* global helpers, btoa, whenDelayedStartupFinished, OpenBrowserWindow */
// Test that screenshot command works properly
"use strict";
const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
"test/browser_cmd_screenshot.html";
var FileUtils = (Cu.import("resource://gre/modules/FileUtils.jsm", {})).FileUtils;
function test() {
// This test gets bombarded by a cascade of GCs and often takes 50s so lets be
// safe and give the test 90s to run.
requestLongerTimeout(3);
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
waitForExplicitFinish();
info("RUN TEST: non-private window");
let normWin = yield addWindow({ private: false });
yield addTabWithToolbarRunTests(normWin);
normWin.close();
info("RUN TEST: private window");
let pbWin = yield addWindow({ private: true });
yield addTabWithToolbarRunTests(pbWin);
pbWin.close();
}
function* addTabWithToolbarRunTests(win) {
let options = yield helpers.openTab(TEST_URI, { chromeWindow: win });
let browser = options.browser;
yield helpers.openToolbar(options);
// Test input status
yield helpers.audit(options, [
{
setup: "screenshot",
check: {
input: "screenshot",
markup: "VVVVVVVVVV",
status: "VALID",
args: {
}
},
},
{
setup: "screenshot abc.png",
check: {
input: "screenshot abc.png",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
filename: { value: "abc.png"},
}
},
},
{
setup: "screenshot --fullpage",
check: {
input: "screenshot --fullpage",
markup: "VVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
fullpage: { value: true},
}
},
},
{
setup: "screenshot abc --delay 5",
check: {
input: "screenshot abc --delay 5",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
filename: { value: "abc"},
delay: { value: 5 },
}
},
},
{
setup: "screenshot --selector img#testImage",
check: {
input: "screenshot --selector img#testImage",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
},
},
]);
// Test capture to file
let file = FileUtils.getFile("TmpD", [ "TestScreenshotFile.png" ]);
yield helpers.audit(options, [
{
setup: "screenshot " + file.path,
check: {
args: {
filename: { value: "" + file.path },
fullpage: { value: false },
clipboard: { value: false },
},
},
exec: {
output: new RegExp("^Saved to "),
},
post: function () {
// Bug 849168: screenshot command tests fail in try but not locally
// ok(file.exists(), "Screenshot file exists");
if (file.exists()) {
file.remove(false);
}
}
},
]);
// Test capture to clipboard
yield helpers.audit(options, [
{
setup: "screenshot --clipboard",
check: {
args: {
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
Assert.equal(imgSize.width, content.innerWidth,
"Image width matches window size");
Assert.equal(imgSize.height, content.innerHeight,
"Image height matches window size");
});
})
},
{
setup: "screenshot --fullpage --clipboard",
check: {
args: {
fullpage: { value: true },
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
Assert.equal(imgSize.width,
content.innerWidth + content.scrollMaxX - content.scrollMinX,
"Image width matches page size");
Assert.equal(imgSize.height,
content.innerHeight + content.scrollMaxY - content.scrollMinY,
"Image height matches page size");
});
})
},
{
setup: "screenshot --selector img#testImage --clipboard",
check: {
args: {
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
let img = content.document.querySelector("img#testImage");
Assert.equal(imgSize.width, img.clientWidth,
"Image width matches element size");
Assert.equal(imgSize.height, img.clientHeight,
"Image height matches element size");
});
})
},
]);
// Trigger scrollbars by forcing document to overflow
// This only affects results on OSes with scrollbars that reduce document size
// (non-floating scrollbars). With default OS settings, this means Windows
// and Linux are affected, but Mac is not. For Mac to exhibit this behavior,
// change System Preferences -> General -> Show scroll bars to Always.
yield ContentTask.spawn(browser, {}, function* () {
content.document.body.classList.add("overflow");
});
let scrollbarSize = yield ContentTask.spawn(browser, {}, function* () {
const winUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let scrollbarHeight = {};
let scrollbarWidth = {};
winUtils.getScrollbarSize(true, scrollbarWidth, scrollbarHeight);
return {
width: scrollbarWidth.value,
height: scrollbarHeight.value,
};
});
info(`Scrollbar size: ${scrollbarSize.width}x${scrollbarSize.height}`);
// Test capture to clipboard in presence of scrollbars
yield helpers.audit(options, [
{
setup: "screenshot --clipboard",
check: {
args: {
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
imgSize1.scrollbarWidth = scrollbarSize.width;
imgSize1.scrollbarHeight = scrollbarSize.height;
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
Assert.equal(imgSize.width, content.innerWidth - imgSize.scrollbarWidth,
"Image width matches window size minus scrollbar size");
Assert.equal(imgSize.height, content.innerHeight - imgSize.scrollbarHeight,
"Image height matches window size minus scrollbar size");
});
})
},
{
setup: "screenshot --fullpage --clipboard",
check: {
args: {
fullpage: { value: true },
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
imgSize1.scrollbarWidth = scrollbarSize.width;
imgSize1.scrollbarHeight = scrollbarSize.height;
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
Assert.equal(imgSize.width,
(content.innerWidth + content.scrollMaxX -
content.scrollMinX) - imgSize.scrollbarWidth,
"Image width matches page size minus scrollbar size");
Assert.equal(imgSize.height,
(content.innerHeight + content.scrollMaxY -
content.scrollMinY) - imgSize.scrollbarHeight,
"Image height matches page size minus scrollbar size");
});
})
},
{
setup: "screenshot --selector img#testImage --clipboard",
check: {
args: {
clipboard: { value: true },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: Task.async(function* () {
let imgSize1 = yield getImageSizeFromClipboard();
yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
let img = content.document.querySelector("img#testImage");
Assert.equal(imgSize.width, img.clientWidth,
"Image width matches element size");
Assert.equal(imgSize.height, img.clientHeight,
"Image height matches element size");
});
})
},
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}
function addWindow(windowOptions) {
return new Promise(resolve => {
let win = OpenBrowserWindow(windowOptions);
// This feels hacky, we should refactor it
whenDelayedStartupFinished(win, () => {
// Would like to get rid of this executeSoon, but without it the url
// (TEST_URI) provided in addTabWithToolbarRunTests hasn't loaded
executeSoon(() => {
resolve(win);
});
});
});
}
let getImageSizeFromClipboard = Task.async(function* () {
let clipid = Ci.nsIClipboard;
let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid);
let trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
let flavor = "image/png";
trans.init(null);
trans.addDataFlavor(flavor);
clip.getData(trans, clipid.kGlobalClipboard);
let data = new Object();
let dataLength = new Object();
trans.getTransferData(flavor, data, dataLength);
ok(data.value, "screenshot exists");
ok(dataLength.value > 0, "screenshot has length");
let image = data.value;
let dataURI = `data:${flavor};base64,`;
// Due to the differences in how images could be stored in the clipboard the
// checks below are needed. The clipboard could already provide the image as
// byte streams, but also as pointer, or as image container. If it's not
// possible obtain a byte stream, the function returns `null`.
if (image instanceof Ci.nsISupportsInterfacePointer) {
image = image.data;
}
if (image instanceof Ci.imgIContainer) {
image = Cc["@mozilla.org/image/tools;1"]
.getService(Ci.imgITools)
.encodeImage(image, flavor);
}
if (image instanceof Ci.nsIInputStream) {
let binaryStream = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
binaryStream.setInputStream(image);
let rawData = binaryStream.readBytes(binaryStream.available());
let charCodes = Array.from(rawData, c => c.charCodeAt(0) & 0xff);
let encodedData = String.fromCharCode(...charCodes);
encodedData = btoa(encodedData);
dataURI = dataURI + encodedData;
} else {
throw new Error("Unable to read image data");
}
let img = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
let loaded = new Promise(resolve => {
img.addEventListener("load", function onLoad() {
img.removeEventListener("load", onLoad);
resolve();
});
});
img.src = dataURI;
document.documentElement.appendChild(img);
yield loaded;
img.remove();
return {
width: img.width,
height: img.height,
};
});

View file

@ -0,0 +1,124 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the pref commands work
var prefBranch = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService).getBranch(null)
.QueryInterface(Ci.nsIPrefBranch2);
var supportsString = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
const TEST_URI = "data:text/html;charset=utf-8,gcli-settings";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
// Setup
let options = yield helpers.openTab(TEST_URI);
const { createSystem } = require("gcli/system");
const system = createSystem({ location: "server" });
const gcliInit = require("devtools/shared/gcli/commands/index");
gcliInit.addAllItemsByModule(system);
yield system.load();
let settings = system.settings;
let hideIntroEnabled = settings.get("devtools.gcli.hideIntro");
let tabSize = settings.get("devtools.editor.tabsize");
let remoteHost = settings.get("devtools.debugger.remote-host");
let hideIntroOrig = prefBranch.getBoolPref("devtools.gcli.hideIntro");
let tabSizeOrig = prefBranch.getIntPref("devtools.editor.tabsize");
let remoteHostOrig = prefBranch.getComplexValue(
"devtools.debugger.remote-host",
Components.interfaces.nsISupportsString).data;
info("originally: devtools.gcli.hideIntro = " + hideIntroOrig);
info("originally: devtools.editor.tabsize = " + tabSizeOrig);
info("originally: devtools.debugger.remote-host = " + remoteHostOrig);
// Actual tests
is(hideIntroEnabled.value, hideIntroOrig, "hideIntroEnabled default");
is(tabSize.value, tabSizeOrig, "tabSize default");
is(remoteHost.value, remoteHostOrig, "remoteHost default");
hideIntroEnabled.setDefault();
tabSize.setDefault();
remoteHost.setDefault();
let hideIntroEnabledDefault = hideIntroEnabled.value;
let tabSizeDefault = tabSize.value;
let remoteHostDefault = remoteHost.value;
hideIntroEnabled.value = false;
tabSize.value = 42;
remoteHost.value = "example.com";
is(hideIntroEnabled.value, false, "hideIntroEnabled basic");
is(tabSize.value, 42, "tabSize basic");
is(remoteHost.value, "example.com", "remoteHost basic");
function hideIntroEnabledCheck(ev) {
is(ev.setting, hideIntroEnabled, "hideIntroEnabled event setting");
is(ev.value, true, "hideIntroEnabled event value");
is(ev.setting.value, true, "hideIntroEnabled event setting value");
}
hideIntroEnabled.onChange.add(hideIntroEnabledCheck);
hideIntroEnabled.value = true;
is(hideIntroEnabled.value, true, "hideIntroEnabled change");
function tabSizeCheck(ev) {
is(ev.setting, tabSize, "tabSize event setting");
is(ev.value, 1, "tabSize event value");
is(ev.setting.value, 1, "tabSize event setting value");
}
tabSize.onChange.add(tabSizeCheck);
tabSize.value = 1;
is(tabSize.value, 1, "tabSize change");
function remoteHostCheck(ev) {
is(ev.setting, remoteHost, "remoteHost event setting");
is(ev.value, "y.com", "remoteHost event value");
is(ev.setting.value, "y.com", "remoteHost event setting value");
}
remoteHost.onChange.add(remoteHostCheck);
remoteHost.value = "y.com";
is(remoteHost.value, "y.com", "remoteHost change");
hideIntroEnabled.onChange.remove(hideIntroEnabledCheck);
tabSize.onChange.remove(tabSizeCheck);
remoteHost.onChange.remove(remoteHostCheck);
function remoteHostReCheck(ev) {
is(ev.setting, remoteHost, "remoteHost event reset");
is(ev.value, null, "remoteHost event revalue");
is(ev.setting.value, null, "remoteHost event setting revalue");
}
remoteHost.onChange.add(remoteHostReCheck);
hideIntroEnabled.setDefault();
tabSize.setDefault();
remoteHost.setDefault();
remoteHost.onChange.remove(remoteHostReCheck);
is(hideIntroEnabled.value, hideIntroEnabledDefault, "hideIntroEnabled reset");
is(tabSize.value, tabSizeDefault, "tabSize reset");
is(remoteHost.value, remoteHostDefault, "remoteHost reset");
// Cleanup
prefBranch.setBoolPref("devtools.gcli.hideIntro", hideIntroOrig);
prefBranch.setIntPref("devtools.editor.tabsize", tabSizeOrig);
supportsString.data = remoteHostOrig;
prefBranch.setComplexValue("devtools.debugger.remote-host",
Components.interfaces.nsISupportsString,
supportsString);
yield helpers.closeTab(options);
}

View file

@ -0,0 +1,110 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_async.js");
}
// var helpers = require('./helpers');
exports.testBasic = function (options) {
return helpers.audit(options, [
{
setup: "tsslo",
check: {
input: "tsslo",
hints: "w",
markup: "IIIII",
cursor: 5,
current: "__command",
status: "ERROR",
predictions: ["tsslow"],
unassigned: [ ]
}
},
{
setup: "tsslo<TAB>",
check: {
input: "tsslow ",
hints: "Shalom",
markup: "VVVVVVV",
cursor: 7,
current: "hello",
status: "ERROR",
predictions: [
"Shalom", "Namasté", "Hallo", "Dydd-da", "Chào", "Hej",
"Saluton", "Sawubona"
],
unassigned: [ ],
args: {
command: { name: "tsslow" },
hello: {
arg: "",
status: "INCOMPLETE"
},
}
}
},
{
setup: "tsslow S",
check: {
input: "tsslow S",
hints: "halom",
markup: "VVVVVVVI",
cursor: 8,
current: "hello",
status: "ERROR",
predictions: [ "Shalom", "Saluton", "Sawubona", "Namasté" ],
unassigned: [ ],
args: {
command: { name: "tsslow" },
hello: {
arg: " S",
status: "INCOMPLETE"
},
}
}
},
{
setup: "tsslow S<TAB>",
check: {
input: "tsslow Shalom ",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "hello",
status: "VALID",
predictions: [ "Shalom" ],
unassigned: [ ],
args: {
command: { name: "tsslow" },
hello: {
arg: " Shalom ",
status: "VALID",
message: ""
},
}
}
}
]);
};

View file

@ -0,0 +1,286 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_canon.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
var Commands = require("gcli/commands/commands").Commands;
var startCount;
var events;
var commandsChange = function (ev) {
events++;
};
exports.setup = function (options) {
startCount = options.requisition.system.commands.getAll().length;
events = 0;
};
exports.shutdown = function (options) {
startCount = undefined;
events = undefined;
};
exports.testAddRemove1 = function (options) {
var commands = options.requisition.system.commands;
return helpers.audit(options, [
{
name: "testadd add",
setup: function () {
commands.onCommandsChange.add(commandsChange);
commands.add({
name: "testadd",
exec: function () {
return 1;
}
});
assert.is(commands.getAll().length,
startCount + 1,
"add command success");
assert.is(events, 1, "add event");
return helpers.setInput(options, "testadd");
},
check: {
input: "testadd",
hints: "",
markup: "VVVVVVV",
cursor: 7,
current: "__command",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: { }
},
exec: {
output: /^1$/
}
},
{
name: "testadd alter",
setup: function () {
commands.add({
name: "testadd",
exec: function () {
return 2;
}
});
assert.is(commands.getAll().length,
startCount + 1,
"read command success");
assert.is(events, 2, "read event");
return helpers.setInput(options, "testadd");
},
check: {
input: "testadd",
hints: "",
markup: "VVVVVVV",
},
exec: {
output: "2"
}
},
{
name: "testadd remove",
setup: function () {
commands.remove("testadd");
assert.is(commands.getAll().length,
startCount,
"remove command success");
assert.is(events, 3, "remove event");
return helpers.setInput(options, "testadd");
},
check: {
typed: "testadd",
cursor: 7,
current: "__command",
status: "ERROR",
unassigned: [ ],
}
}
]);
};
exports.testAddRemove2 = function (options) {
var commands = options.requisition.system.commands;
commands.add({
name: "testadd",
exec: function () {
return 3;
}
});
assert.is(commands.getAll().length,
startCount + 1,
"rereadd command success");
assert.is(events, 4, "rereadd event");
return helpers.audit(options, [
{
setup: "testadd",
exec: {
output: /^3$/
},
post: function () {
commands.remove({
name: "testadd"
});
assert.is(commands.getAll().length,
startCount,
"reremove command success");
assert.is(events, 5, "reremove event");
}
},
{
setup: "testadd",
check: {
typed: "testadd",
status: "ERROR"
}
}
]);
};
exports.testAddRemove3 = function (options) {
var commands = options.requisition.system.commands;
commands.remove({ name: "nonexistant" });
assert.is(commands.getAll().length,
startCount,
"nonexistant1 command success");
assert.is(events, 5, "nonexistant1 event");
commands.remove("nonexistant");
assert.is(commands.getAll().length,
startCount,
"nonexistant2 command success");
assert.is(events, 5, "nonexistant2 event");
commands.onCommandsChange.remove(commandsChange);
};
exports.testAltCommands = function (options) {
var commands = options.requisition.system.commands;
var altCommands = new Commands(options.requisition.system.types);
var tss = {
name: "tss",
params: [
{ name: "str", type: "string" },
{ name: "num", type: "number" },
{ name: "opt", type: { name: "selection", data: [ "1", "2", "3" ] } },
],
customProp1: "localValue",
customProp2: true,
customProp3: 42,
exec: function (args, context) {
return context.commandName + ":" +
args.str + ":" + args.num + ":" + args.opt;
}
};
altCommands.add(tss);
var commandSpecs = altCommands.getCommandSpecs();
assert.is(JSON.stringify(commandSpecs),
'[{"item":"command","name":"tss","params":[' +
'{"name":"str","type":"string"},' +
'{"name":"num","type":"number"},' +
'{"name":"opt","type":{"name":"selection","data":["1","2","3"]}}' +
'],"isParent":false}]',
"JSON.stringify(commandSpecs)");
var customProps = [ "customProp1", "customProp2", "customProp3", ];
var commandSpecs2 = altCommands.getCommandSpecs(customProps);
assert.is(JSON.stringify(commandSpecs2),
"[{" +
'"item":"command",' +
'"name":"tss",' +
'"params":[' +
'{"name":"str","type":"string"},' +
'{"name":"num","type":"number"},' +
'{"name":"opt","type":{"name":"selection","data":["1","2","3"]}}' +
"]," +
'"isParent":false,' +
'"customProp1":"localValue",' +
'"customProp2":true,' +
'"customProp3":42' +
"}]",
"JSON.stringify(commandSpecs)");
var remoter = function (args, context) {
assert.is(context.commandName, "tss", "commandName is tss");
var cmd = altCommands.get(context.commandName);
return cmd.exec(args, context);
};
commands.addProxyCommands(commandSpecs, remoter, "proxy", "test");
var parent = commands.get("proxy");
assert.is(parent.name, "proxy", "Parent command called proxy");
var child = commands.get("proxy tss");
assert.is(child.name, "proxy tss", "child command called proxy tss");
return helpers.audit(options, [
{
setup: "proxy tss foo 6 3",
check: {
input: "proxy tss foo 6 3",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
status: "VALID",
args: {
str: { value: "foo", status: "VALID" },
num: { value: 6, status: "VALID" },
opt: { value: "3", status: "VALID" }
}
},
exec: {
output: "tss:foo:6:3"
},
post: function () {
commands.remove("proxy");
commands.remove("proxy tss");
assert.is(commands.get("proxy"), undefined, "remove proxy");
assert.is(commands.get("proxy tss"), undefined, "remove proxy tss");
}
}
]);
};

View file

@ -0,0 +1,528 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_cli1.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
exports.testBlank = function (options) {
return helpers.audit(options, [
{
setup: "",
check: {
input: "",
hints: "",
markup: "",
cursor: 0,
current: "__command",
status: "ERROR"
},
post: function () {
assert.is(options.requisition.commandAssignment.value, undefined);
}
},
{
setup: " ",
check: {
input: " ",
hints: "",
markup: "V",
cursor: 1,
current: "__command",
status: "ERROR"
},
post: function () {
assert.is(options.requisition.commandAssignment.value, undefined);
}
},
{
name: "| ",
setup: function () {
return helpers.setInput(options, " ", 0);
},
check: {
input: " ",
hints: "",
markup: "V",
cursor: 0,
current: "__command",
status: "ERROR"
},
post: function () {
assert.is(options.requisition.commandAssignment.value, undefined);
}
}
]);
};
exports.testDelete = function (options) {
return helpers.audit(options, [
{
setup: "x<BACKSPACE>",
check: {
input: "",
hints: "",
markup: "",
cursor: 0,
current: "__command",
status: "ERROR"
},
post: function () {
assert.is(options.requisition.commandAssignment.value, undefined);
}
}
]);
};
exports.testIncompleteMultiMatch = function (options) {
return helpers.audit(options, [
{
setup: "tsn ex",
check: {
input: "tsn ex",
hints: "t",
markup: "IIIVII",
cursor: 6,
current: "__command",
status: "ERROR",
predictionsContains: [
"tsn ext", "tsn exte", "tsn exten", "tsn extend"
]
}
}
]);
};
exports.testIncompleteSingleMatch = function (options) {
return helpers.audit(options, [
{
setup: "tselar",
check: {
input: "tselar",
hints: "r",
markup: "IIIIII",
cursor: 6,
current: "__command",
status: "ERROR",
predictions: [ "tselarr" ],
unassigned: [ ]
}
}
]);
};
exports.testTsv = function (options) {
return helpers.audit(options, [
{
setup: "tsv",
check: {
input: "tsv",
hints: " <optionType> <optionValue>",
markup: "VVV",
cursor: 3,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: { arg: "", status: "INCOMPLETE" },
optionValue: { arg: "", status: "INCOMPLETE" }
}
}
},
{
setup: "tsv ",
check: {
input: "tsv ",
hints: "option1 <optionValue>",
markup: "VVVV",
cursor: 4,
current: "optionType",
status: "ERROR",
predictions: [ "option1", "option2", "option3" ],
unassigned: [ ],
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tsv" },
optionType: { arg: "", status: "INCOMPLETE" },
optionValue: { arg: "", status: "INCOMPLETE" }
}
}
},
{
name: "ts|v",
setup: function () {
return helpers.setInput(options, "tsv ", 2);
},
check: {
input: "tsv ",
hints: "<optionType> <optionValue>",
markup: "VVVV",
cursor: 2,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: { arg: "", status: "INCOMPLETE" },
optionValue: { arg: "", status: "INCOMPLETE" }
}
}
},
{
setup: "tsv o",
check: {
input: "tsv o",
hints: "ption1 <optionValue>",
markup: "VVVVI",
cursor: 5,
current: "optionType",
status: "ERROR",
predictions: [ "option1", "option2", "option3" ],
unassigned: [ ],
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tsv" },
optionType: {
value: undefined,
arg: " o",
status: "INCOMPLETE",
message: "Value required for \u2018optionType\u2019."
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
setup: "tsv option",
check: {
input: "tsv option",
hints: "1 <optionValue>",
markup: "VVVVIIIIII",
cursor: 10,
current: "optionType",
status: "ERROR",
predictions: [ "option1", "option2", "option3" ],
unassigned: [ ],
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tsv" },
optionType: {
value: undefined,
arg: " option",
status: "INCOMPLETE",
message: "Value required for \u2018optionType\u2019."
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
name: "|tsv option",
setup: function () {
return helpers.setInput(options, "tsv option", 0);
},
check: {
input: "tsv option",
hints: " <optionValue>",
markup: "VVVVEEEEEE",
cursor: 0,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: undefined,
arg: " option",
status: "INCOMPLETE",
message: "Value required for \u2018optionType\u2019."
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
setup: "tsv option ",
check: {
input: "tsv option ",
hints: "<optionValue>",
markup: "VVVVEEEEEEV",
cursor: 11,
current: "optionValue",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "false:default",
args: {
command: { name: "tsv" },
optionType: {
value: undefined,
arg: " option ",
status: "ERROR",
message: "Can\u2019t use \u2018option\u2019."
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
setup: "tsv option1",
check: {
input: "tsv option1",
hints: " <optionValue>",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "optionType",
status: "ERROR",
predictions: [ "option1" ],
unassigned: [ ],
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tsv" },
optionType: {
value: "string",
arg: " option1",
status: "VALID",
message: ""
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
setup: "tsv option1 ",
check: {
input: "tsv option1 ",
hints: "<optionValue>",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "optionValue",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: "string",
arg: " option1 ",
status: "VALID",
message: ""
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
},
{
setup: "tsv option2",
check: {
input: "tsv option2",
hints: " <optionValue>",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "optionType",
status: "ERROR",
predictions: [ "option2" ],
unassigned: [ ],
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tsv" },
optionType: {
value: "number",
arg: " option2",
status: "VALID",
message: ""
},
optionValue: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018optionValue\u2019."
}
}
}
}
]);
};
exports.testTsvValues = function (options) {
return helpers.audit(options, [
{
setup: "tsv option1 6",
check: {
input: "tsv option1 6",
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "optionValue",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: "string",
arg: " option1",
status: "VALID",
message: ""
},
optionValue: {
arg: " 6",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsv option2 6",
check: {
input: "tsv option2 6",
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "optionValue",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: "number",
arg: " option2",
status: "VALID",
message: ""
},
optionValue: {
arg: " 6",
status: "VALID",
message: ""
}
}
}
},
// Delegated remote types can't transfer value types so we only test for
// the value of 'value' when we're local
{
skipIf: options.isRemote,
setup: "tsv option1 6",
check: {
args: {
optionValue: { value: "6" }
}
}
},
{
skipIf: options.isRemote,
setup: "tsv option2 6",
check: {
args: {
optionValue: { value: 6 }
}
}
}
]);
};
exports.testInvalid = function (options) {
return helpers.audit(options, [
{
setup: "zxjq",
check: {
input: "zxjq",
hints: "",
markup: "EEEE",
cursor: 4,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError"
}
},
{
setup: "zxjq ",
check: {
input: "zxjq ",
hints: "",
markup: "EEEEV",
cursor: 5,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError"
}
},
{
setup: "zxjq one",
check: {
input: "zxjq one",
hints: "",
markup: "EEEEVEEE",
cursor: 8,
current: "__unassigned",
status: "ERROR",
predictions: [ ],
unassigned: [ " one" ],
tooltipState: "true:isError"
}
}
]);
};

View file

@ -0,0 +1,788 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_cli2.js");
}
// var helpers = require('./helpers');
exports.testSingleString = function (options) {
return helpers.audit(options, [
{
setup: "tsr",
check: {
input: "tsr",
hints: " <text>",
markup: "VVV",
cursor: 3,
current: "__command",
status: "ERROR",
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsr ",
check: {
input: "tsr ",
hints: "<text>",
markup: "VVVV",
cursor: 4,
current: "text",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsr h",
check: {
input: "tsr h",
hints: "",
markup: "VVVVV",
cursor: 5,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "h",
arg: " h",
status: "VALID",
message: ""
}
}
}
},
{
setup: 'tsr "h h"',
check: {
input: 'tsr "h h"',
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "h h",
arg: ' "h h"',
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsr h h h",
check: {
input: "tsr h h h",
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "h h h",
arg: " h h h",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testSingleNumber = function (options) {
return helpers.audit(options, [
{
setup: "tsu",
check: {
input: "tsu",
hints: " <num>",
markup: "VVV",
cursor: 3,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018num\u2019."
}
}
}
},
{
setup: "tsu ",
check: {
input: "tsu ",
hints: "<num>",
markup: "VVVV",
cursor: 4,
current: "num",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018num\u2019."
}
}
}
},
{
setup: "tsu 1",
check: {
input: "tsu 1",
hints: "",
markup: "VVVVV",
cursor: 5,
current: "num",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: { value: 1, arg: " 1", status: "VALID", message: "" }
}
}
},
{
setup: "tsu x",
check: {
input: "tsu x",
hints: "",
markup: "VVVVE",
cursor: 5,
current: "num",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError",
args: {
command: { name: "tsu" },
num: {
value: undefined,
arg: " x",
status: "ERROR",
message: "Can\u2019t convert \u201cx\u201d to a number."
}
}
}
},
{
setup: "tsu 1.5",
check: {
input: "tsu 1.5",
hints: "",
markup: "VVVVEEE",
cursor: 7,
current: "num",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: {
value: undefined,
arg: " 1.5",
status: "ERROR",
message: "Can\u2019t convert \u201c1.5\u201d to an integer."
}
}
}
}
]);
};
exports.testSingleFloat = function (options) {
return helpers.audit(options, [
{
setup: "tsf",
check: {
input: "tsf",
hints: " <num>",
markup: "VVV",
cursor: 3,
current: "__command",
status: "ERROR",
error: "",
unassigned: [ ],
args: {
command: { name: "tsf" },
num: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018num\u2019."
}
}
}
},
{
setup: "tsf 1",
check: {
input: "tsf 1",
hints: "",
markup: "VVVVV",
cursor: 5,
current: "num",
status: "VALID",
error: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsf" },
num: { value: 1, arg: " 1", status: "VALID", message: "" }
}
}
},
{
setup: "tsf 1.",
check: {
input: "tsf 1.",
hints: "",
markup: "VVVVVV",
cursor: 6,
current: "num",
status: "VALID",
error: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsf" },
num: { value: 1, arg: " 1.", status: "VALID", message: "" }
}
}
},
{
setup: "tsf 1.5",
check: {
input: "tsf 1.5",
hints: "",
markup: "VVVVVVV",
cursor: 7,
current: "num",
status: "VALID",
error: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsf" },
num: { value: 1.5, arg: " 1.5", status: "VALID", message: "" }
}
}
},
{
setup: "tsf 1.5x",
check: {
input: "tsf 1.5x",
hints: "",
markup: "VVVVVVVV",
cursor: 8,
current: "num",
status: "VALID",
error: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsf" },
num: { value: 1.5, arg: " 1.5x", status: "VALID", message: "" }
}
}
},
{
name: "tsf x (cursor=4)",
setup: function () {
return helpers.setInput(options, "tsf x", 4);
},
check: {
input: "tsf x",
hints: "",
markup: "VVVVE",
cursor: 4,
current: "num",
status: "ERROR",
error: "Can\u2019t convert \u201cx\u201d to a number.",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsf" },
num: {
value: undefined,
arg: " x",
status: "ERROR",
message: "Can\u2019t convert \u201cx\u201d to a number."
}
}
}
}
]);
};
exports.testElementWeb = function (options) {
return helpers.audit(options, [
{
setup: "tse #gcli-root",
check: {
input: "tse #gcli-root",
hints: " [options]",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "node",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tse" },
node: {
arg: " #gcli-root",
status: "VALID",
message: ""
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
}
]);
};
exports.testElement = function (options) {
return helpers.audit(options, [
{
setup: "tse",
check: {
input: "tse",
hints: " <node> [options]",
markup: "VVV",
cursor: 3,
current: "__command",
status: "ERROR",
predictions: [ "tse", "tselarr" ],
unassigned: [ ],
args: {
command: { name: "tse" },
node: { arg: "", status: "INCOMPLETE" },
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
},
{
setup: "tse #gcli-nomatch",
check: {
input: "tse #gcli-nomatch",
hints: " [options]",
markup: "VVVVIIIIIIIIIIIII",
cursor: 17,
current: "node",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
outputState: "false:default",
tooltipState: "true:isError",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " #gcli-nomatch",
// This is somewhat debatable because this input can't be corrected
// simply by typing so it's and error rather than incomplete,
// however without digging into the CSS engine we can't tell that
// so we default to incomplete
status: "INCOMPLETE",
message: "No matches"
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
},
{
setup: "tse #",
check: {
input: "tse #",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " #",
status: "ERROR",
message: "Syntax error in CSS query"
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
},
{
setup: "tse .",
check: {
input: "tse .",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " .",
status: "ERROR",
message: "Syntax error in CSS query"
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
},
{
setup: "tse *",
check: {
input: "tse *",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " *",
status: "ERROR",
message: /^Too many matches \([0-9]*\)/
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: "", status: "VALID", message: "" },
}
}
}
]);
};
exports.testNestedCommand = function (options) {
return helpers.audit(options, [
{
setup: "tsn",
check: {
input: "tsn",
hints: " deep down nested cmd",
markup: "III",
cursor: 3,
current: "__command",
status: "ERROR",
predictionsInclude: [
"tsn deep", "tsn deep down", "tsn deep down nested",
"tsn deep down nested cmd", "tsn dif"
],
unassigned: [ ],
args: {
command: { name: "tsn" }
}
}
},
{
setup: "tsn ",
check: {
input: "tsn ",
hints: " deep down nested cmd",
markup: "IIIV",
cursor: 4,
current: "__command",
status: "ERROR",
unassigned: [ ]
}
},
{
skipIf: options.isPhantomjs, // PhantomJS gets predictions wrong
setup: "tsn x",
check: {
input: "tsn x",
hints: " -> tsn ext",
markup: "IIIVI",
cursor: 5,
current: "__command",
status: "ERROR",
predictions: [ "tsn ext" ],
unassigned: [ ]
}
},
{
setup: "tsn dif",
check: {
input: "tsn dif",
hints: " <text>",
markup: "VVVVVVV",
cursor: 7,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn dif" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsn dif ",
check: {
input: "tsn dif ",
hints: "<text>",
markup: "VVVVVVVV",
cursor: 8,
current: "text",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn dif" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsn dif x",
check: {
input: "tsn dif x",
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn dif" },
text: { value: "x", arg: " x", status: "VALID", message: "" }
}
}
},
{
setup: "tsn ext",
check: {
input: "tsn ext",
hints: " <text>",
markup: "VVVVVVV",
cursor: 7,
current: "__command",
status: "ERROR",
predictions: [ "tsn ext", "tsn exte", "tsn exten", "tsn extend" ],
unassigned: [ ],
args: {
command: { name: "tsn ext" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsn exte",
check: {
input: "tsn exte",
hints: " <text>",
markup: "VVVVVVVV",
cursor: 8,
current: "__command",
status: "ERROR",
predictions: [ "tsn exte", "tsn exten", "tsn extend" ],
unassigned: [ ],
args: {
command: { name: "tsn exte" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsn exten",
check: {
input: "tsn exten",
hints: " <text>",
markup: "VVVVVVVVV",
cursor: 9,
current: "__command",
status: "ERROR",
predictions: [ "tsn exten", "tsn extend" ],
unassigned: [ ],
args: {
command: { name: "tsn exten" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "tsn extend",
check: {
input: "tsn extend",
hints: " <text>",
markup: "VVVVVVVVVV",
cursor: 10,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn extend" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for \u2018text\u2019."
}
}
}
},
{
setup: "ts ",
check: {
input: "ts ",
hints: "",
markup: "EEV",
cursor: 3,
current: "__command",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
tooltipState: "true:isError"
}
},
]);
};
// From Bug 664203
exports.testDeeplyNested = function (options) {
return helpers.audit(options, [
{
setup: "tsn deep down nested",
check: {
input: "tsn deep down nested",
hints: " cmd",
markup: "IIIVIIIIVIIIIVIIIIII",
cursor: 20,
current: "__command",
status: "ERROR",
predictions: [ "tsn deep down nested cmd" ],
unassigned: [ ],
outputState: "false:default",
tooltipState: "false:default",
args: {
command: { name: "tsn deep down nested" },
}
}
},
{
setup: "tsn deep down nested cmd",
check: {
input: "tsn deep down nested cmd",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 24,
current: "__command",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn deep down nested cmd" },
}
}
}
]);
};

View file

@ -0,0 +1,277 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_completion1.js");
}
// var helpers = require('./helpers');
exports.testActivate = function (options) {
return helpers.audit(options, [
{
setup: "",
check: {
hints: ""
}
},
{
setup: " ",
check: {
hints: ""
}
},
{
setup: "tsr",
check: {
hints: " <text>"
}
},
{
setup: "tsr ",
check: {
hints: "<text>"
}
},
{
setup: "tsr b",
check: {
hints: ""
}
},
{
setup: "tsb",
check: {
hints: " [toggle]"
}
},
{
setup: "tsm",
check: {
hints: " <abc> <txt> <num>"
}
},
{
setup: "tsm ",
check: {
hints: "a <txt> <num>"
}
},
{
setup: "tsm a",
check: {
hints: " <txt> <num>"
}
},
{
setup: "tsm a ",
check: {
hints: "<txt> <num>"
}
},
{
setup: "tsm a ",
check: {
hints: "<txt> <num>"
}
},
{
setup: "tsm a d",
check: {
hints: " <num>"
}
},
{
setup: 'tsm a "d d"',
check: {
hints: " <num>"
}
},
{
setup: 'tsm a "d ',
check: {
hints: " <num>"
}
},
{
setup: 'tsm a "d d" ',
check: {
hints: "<num>"
}
},
{
setup: 'tsm a "d d ',
check: {
hints: " <num>"
}
},
{
setup: "tsm d r",
check: {
hints: " <num>"
}
},
{
setup: "tsm a d ",
check: {
hints: "<num>"
}
},
{
setup: "tsm a d 4",
check: {
hints: ""
}
},
{
setup: "tsg",
check: {
hints: " <solo> [options]"
}
},
{
setup: "tsg ",
check: {
hints: "aaa [options]"
}
},
{
setup: "tsg a",
check: {
hints: "aa [options]"
}
},
{
setup: "tsg b",
check: {
hints: "bb [options]"
}
},
{
skipIf: options.isPhantomjs, // PhantomJS gets predictions wrong
setup: "tsg d",
check: {
hints: " [options] -> ccc"
}
},
{
setup: "tsg aa",
check: {
hints: "a [options]"
}
},
{
setup: "tsg aaa",
check: {
hints: " [options]"
}
},
{
setup: "tsg aaa ",
check: {
hints: "[options]"
}
},
{
setup: "tsg aaa d",
check: {
hints: " [options]"
}
},
{
setup: "tsg aaa dddddd",
check: {
hints: " [options]"
}
},
{
setup: "tsg aaa dddddd ",
check: {
hints: "[options]"
}
},
{
setup: 'tsg aaa "d',
check: {
hints: " [options]"
}
},
{
setup: 'tsg aaa "d d',
check: {
hints: " [options]"
}
},
{
setup: 'tsg aaa "d d"',
check: {
hints: " [options]"
}
},
{
setup: "tsn ex ",
check: {
hints: ""
}
},
{
setup: "selarr",
check: {
hints: " -> tselarr"
}
},
{
setup: "tselar 1",
check: {
hints: ""
}
},
{
name: "tselar |1",
setup: function () {
return helpers.setInput(options, "tselar 1", 7);
},
check: {
hints: ""
}
},
{
name: "tselar| 1",
setup: function () {
return helpers.setInput(options, "tselar 1", 6);
},
check: {
hints: " -> tselarr"
}
},
{
name: "tsela|r 1",
setup: function () {
return helpers.setInput(options, "tselar 1", 5);
},
check: {
hints: " -> tselarr"
}
},
]);
};

View file

@ -0,0 +1,263 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_completion2.js");
}
// var helpers = require('./helpers');
exports.testLong = function (options) {
return helpers.audit(options, [
{
setup: "tslong --sel",
check: {
input: "tslong --sel",
hints: " <selection> <msg> [options]",
markup: "VVVVVVVIIIII"
}
},
{
setup: "tslong --sel<TAB>",
check: {
input: "tslong --sel ",
hints: "space <msg> [options]",
markup: "VVVVVVVIIIIIV"
}
},
{
setup: "tslong --sel ",
check: {
input: "tslong --sel ",
hints: "space <msg> [options]",
markup: "VVVVVVVIIIIIV"
}
},
{
setup: "tslong --sel s",
check: {
input: "tslong --sel s",
hints: "pace <msg> [options]",
markup: "VVVVVVVIIIIIVI"
}
},
{
setup: "tslong --num ",
check: {
input: "tslong --num ",
hints: "<number> <msg> [options]",
markup: "VVVVVVVIIIIIV"
}
},
{
setup: "tslong --num 42",
check: {
input: "tslong --num 42",
hints: " <msg> [options]",
markup: "VVVVVVVVVVVVVVV"
}
},
{
setup: "tslong --num 42 ",
check: {
input: "tslong --num 42 ",
hints: "<msg> [options]",
markup: "VVVVVVVVVVVVVVVV"
}
},
{
setup: "tslong --num 42 --se",
check: {
input: "tslong --num 42 --se",
hints: "l <msg> [options]",
markup: "VVVVVVVVVVVVVVVVIIII"
}
},
{
setup: "tslong --num 42 --se<TAB>",
check: {
input: "tslong --num 42 --sel ",
hints: "space <msg> [options]",
markup: "VVVVVVVVVVVVVVVVIIIIIV"
}
},
{
setup: "tslong --num 42 --se<TAB><TAB>",
check: {
input: "tslong --num 42 --sel space ",
hints: "<msg> [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV"
}
},
{
setup: "tslong --num 42 --sel ",
check: {
input: "tslong --num 42 --sel ",
hints: "space <msg> [options]",
markup: "VVVVVVVVVVVVVVVVIIIIIV"
}
},
{
setup: "tslong --num 42 --sel space ",
check: {
input: "tslong --num 42 --sel space ",
hints: "<msg> [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV"
}
}
]);
};
exports.testNoTab = function (options) {
return helpers.audit(options, [
{
setup: "tss<TAB>",
check: {
input: "tss ",
markup: "VVVV",
hints: ""
}
},
{
setup: "tss<TAB><TAB>",
check: {
input: "tss ",
markup: "VVVV",
hints: ""
}
},
{
setup: "xxxx",
check: {
input: "xxxx",
markup: "EEEE",
hints: ""
}
},
{
name: "<TAB>",
setup: function () {
// Doing it this way avoids clearing the input buffer
return helpers.pressTab(options);
},
check: {
input: "xxxx",
markup: "EEEE",
hints: ""
}
}
]);
};
exports.testOutstanding = function (options) {
// See bug 779800
/*
return helpers.audit(options, [
{
setup: 'tsg --txt1 ddd ',
check: {
input: 'tsg --txt1 ddd ',
hints: 'aaa [options]',
markup: 'VVVVVVVVVVVVVVV'
}
},
]);
*/
};
exports.testCompleteIntoOptional = function (options) {
// From bug 779816
return helpers.audit(options, [
{
setup: "tso ",
check: {
typed: "tso ",
hints: "[text]",
markup: "VVVV",
status: "VALID"
}
},
{
setup: "tso<TAB>",
check: {
typed: "tso ",
hints: "[text]",
markup: "VVVV",
status: "VALID"
}
}
]);
};
exports.testSpaceComplete = function (options) {
return helpers.audit(options, [
{
setup: "tslong --sel2 wit",
check: {
input: "tslong --sel2 wit",
hints: "h space <msg> [options]",
markup: "VVVVVVVIIIIIIVIII",
cursor: 17,
current: "sel2",
status: "ERROR",
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tslong" },
msg: { status: "INCOMPLETE" },
num: { status: "VALID" },
sel: { status: "VALID" },
bool: { value: false, status: "VALID" },
num2: { status: "VALID" },
bool2: { value: false, status: "VALID" },
sel2: { arg: " --sel2 wit", status: "INCOMPLETE" }
}
}
},
{
setup: "tslong --sel2 wit<TAB>",
check: {
input: "tslong --sel2 'with space' ",
hints: "<msg> [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 27,
current: "sel2",
status: "ERROR",
tooltipState: "true:importantFieldFlag",
args: {
command: { name: "tslong" },
msg: { status: "INCOMPLETE" },
num: { status: "VALID" },
sel: { status: "VALID" },
bool: { value: false, status: "VALID" },
num2: { status: "VALID" },
bool2: { value: false, status: "VALID" },
sel2: {
value: "with space",
arg: " --sel2 'with space' ",
status: "VALID"
}
}
}
}
]);
};

View file

@ -0,0 +1,239 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_context.js");
}
// var helpers = require('./helpers');
exports.testBaseline = function (options) {
return helpers.audit(options, [
// These 3 establish a baseline for comparison when we have used the
// context command
{
setup: "ext",
check: {
input: "ext",
hints: " -> context",
markup: "III",
message: "",
predictions: [ "context", "tsn ext", "tsn exte", "tsn exten", "tsn extend" ],
unassigned: [ ],
}
},
{
setup: "ext test",
check: {
input: "ext test",
hints: "",
markup: "IIIVEEEE",
status: "ERROR",
message: "Too many arguments",
unassigned: [ " test" ],
}
},
{
setup: "tsn",
check: {
input: "tsn",
hints: " deep down nested cmd",
markup: "III",
cursor: 3,
current: "__command",
status: "ERROR",
predictionsContains: [ "tsn deep down nested cmd", "tsn ext", "tsn exte" ],
args: {
command: { name: "tsn" },
}
}
}
]);
};
exports.testContext = function (options) {
return helpers.audit(options, [
// Use the 'tsn' context
{
setup: "context tsn",
check: {
input: "context tsn",
hints: " deep down nested cmd",
markup: "VVVVVVVVVVV",
message: "",
predictionsContains: [ "tsn deep down nested cmd", "tsn ext", "tsn exte" ],
args: {
command: { name: "context" },
prefix: {
value: options.requisition.system.commands.get("tsn"),
status: "VALID",
message: ""
}
}
},
exec: {
output: "Using tsn as a command prefix"
}
},
// For comparison with earlier
{
setup: "ext",
check: {
input: "ext",
hints: " <text>",
markup: "VVV",
predictions: [ "tsn ext", "tsn exte", "tsn exten", "tsn extend" ],
args: {
command: { name: "tsn ext" },
text: {
value: undefined,
arg: "",
status: "INCOMPLETE"
}
}
}
},
{
setup: "ext test",
check: {
input: "ext test",
hints: "",
markup: "VVVVVVVV",
args: {
command: { name: "tsn ext" },
text: {
value: "test",
arg: " test",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsnExt text=test"
}
},
{
setup: "tsn",
check: {
input: "tsn",
hints: " deep down nested cmd",
markup: "III",
message: "",
predictionsContains: [ "tsn deep down nested cmd", "tsn ext", "tsn exte" ],
args: {
command: { name: "tsn" },
}
}
},
// Does it actually work?
{
setup: "tsb true",
check: {
input: "tsb true",
hints: "",
markup: "VVVVVVVV",
options: [ "true" ],
message: "",
predictions: [ "true" ],
unassigned: [ ],
args: {
command: { name: "tsb" },
toggle: { value: true, arg: " true", status: "VALID", message: "" }
}
}
},
{
// Bug 866710 - GCLI should allow argument merging for non-string parameters
setup: "context tsn ext",
skip: true
},
{
setup: 'context "tsn ext"',
check: {
input: 'context "tsn ext"',
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
message: "",
predictions: [ "tsn ext", "tsn exte", "tsn exten", "tsn extend" ],
unassigned: [ ],
args: {
command: { name: "context" },
prefix: {
value: options.requisition.system.commands.get("tsn ext"),
status: "VALID",
message: ""
}
}
},
exec: {
output: "Can't use 'tsn ext' as a prefix because it is not a parent command.",
error: true
}
},
/*
{
setup: 'context "tsn deep"',
check: {
input: 'context "tsn deep"',
hints: '',
markup: 'VVVVVVVVVVVVVVVVVV',
status: 'ERROR',
message: '',
predictions: [ 'tsn deep' ],
unassigned: [ ],
args: {
command: { name: 'context' },
prefix: {
value: options.requisition.system.commands.get('tsn deep'),
status: 'VALID',
message: ''
}
}
},
exec: {
output: ''
}
},
*/
{
setup: "context",
check: {
input: "context",
hints: " [prefix]",
markup: "VVVVVVV",
status: "VALID",
unassigned: [ ],
args: {
command: { name: "context" },
prefix: { value: undefined, arg: "", status: "VALID", message: "" },
}
},
exec: {
output: "Command prefix is unset",
type: "string",
error: false
}
}
]);
};

View file

@ -0,0 +1,358 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_date.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
var Status = require("gcli/types/types").Status;
exports.testParse = function (options) {
var date = options.requisition.system.types.createType("date");
return date.parseString("now").then(function (conversion) {
// Date comparison - these 2 dates may not be the same, but how close is
// close enough? If this test takes more than 30secs to run the it will
// probably time out, so we'll assume that these 2 values must be within
// 1 min of each other
var gap = new Date().getTime() - conversion.value.getTime();
assert.ok(gap < 60000, "now is less than a minute away");
assert.is(conversion.getStatus(), Status.VALID, "now parse");
});
};
exports.testMaxMin = function (options) {
var max = new Date();
var min = new Date();
var types = options.requisition.system.types;
var date = types.createType({ name: "date", max: max, min: min });
assert.is(date.getMax(), max, "max setup");
var incremented = date.nudge(min, 1);
assert.is(incremented, max, "incremented");
};
exports.testIncrement = function (options) {
var date = options.requisition.system.types.createType("date");
return date.parseString("now").then(function (conversion) {
var plusOne = date.nudge(conversion.value, 1);
var minusOne = date.nudge(plusOne, -1);
// See comments in testParse
var gap = new Date().getTime() - minusOne.getTime();
assert.ok(gap < 60000, "now is less than a minute away");
});
};
exports.testInput = function (options) {
return helpers.audit(options, [
{
setup: "tsdate 2001-01-01 1980-01-03",
check: {
input: "tsdate 2001-01-01 1980-01-03",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
assert.is(d1.getFullYear(), 2001, "d1 year");
assert.is(d1.getMonth(), 0, "d1 month");
assert.is(d1.getDate(), 1, "d1 date");
assert.is(d1.getHours(), 0, "d1 hours");
assert.is(d1.getMinutes(), 0, "d1 minutes");
assert.is(d1.getSeconds(), 0, "d1 seconds");
assert.is(d1.getMilliseconds(), 0, "d1 millis");
},
arg: " 2001-01-01",
status: "VALID",
message: ""
},
d2: {
value: function (d2) {
assert.is(d2.getFullYear(), 1980, "d2 year");
assert.is(d2.getMonth(), 0, "d2 month");
assert.is(d2.getDate(), 3, "d2 date");
assert.is(d2.getHours(), 0, "d2 hours");
assert.is(d2.getMinutes(), 0, "d2 minutes");
assert.is(d2.getSeconds(), 0, "d2 seconds");
assert.is(d2.getMilliseconds(), 0, "d2 millis");
},
arg: " 1980-01-03",
status: "VALID",
message: ""
},
}
},
exec: {
output: [ /^Exec: tsdate/, /2001/, /1980/ ],
type: "testCommandOutput",
error: false
}
},
{
setup: "tsdate 2001/01/01 1980/01/03",
check: {
input: "tsdate 2001/01/01 1980/01/03",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
assert.is(d1.getFullYear(), 2001, "d1 year");
assert.is(d1.getMonth(), 0, "d1 month");
assert.is(d1.getDate(), 1, "d1 date");
assert.is(d1.getHours(), 0, "d1 hours");
assert.is(d1.getMinutes(), 0, "d1 minutes");
assert.is(d1.getSeconds(), 0, "d1 seconds");
assert.is(d1.getMilliseconds(), 0, "d1 millis");
},
arg: " 2001/01/01",
status: "VALID",
message: ""
},
d2: {
value: function (d2) {
assert.is(d2.getFullYear(), 1980, "d2 year");
assert.is(d2.getMonth(), 0, "d2 month");
assert.is(d2.getDate(), 3, "d2 date");
assert.is(d2.getHours(), 0, "d2 hours");
assert.is(d2.getMinutes(), 0, "d2 minutes");
assert.is(d2.getSeconds(), 0, "d2 seconds");
assert.is(d2.getMilliseconds(), 0, "d2 millis");
},
arg: " 1980/01/03",
status: "VALID",
message: ""
},
}
},
exec: {
output: [ /^Exec: tsdate/, /2001/, /1980/ ],
type: "testCommandOutput",
error: false
}
},
{
setup: "tsdate now today",
check: {
input: "tsdate now today",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
// How long should we allow between d1 and now? Mochitest will
// time out after 30 secs, so that seems like a decent upper
// limit, although 30 ms should probably do it. I don't think
// reducing the limit from 30 secs will find any extra bugs
assert.ok(d1.getTime() - new Date().getTime() < 30 * 1000,
"d1 time");
},
arg: " now",
status: "VALID",
message: ""
},
d2: {
value: function (d2) {
// See comment for d1 above
assert.ok(d2.getTime() - new Date().getTime() < 30 * 1000,
"d2 time");
},
arg: " today",
status: "VALID",
message: ""
},
}
},
exec: {
output: [ /^Exec: tsdate/, new Date().getFullYear() ],
type: "testCommandOutput",
error: false
}
},
{
setup: "tsdate yesterday tomorrow",
check: {
input: "tsdate yesterday tomorrow",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
var compare = new Date().getTime() - (24 * 60 * 60 * 1000);
// See comment for d1 in the test for 'tsdate now today'
assert.ok(d1.getTime() - compare < 30 * 1000,
"d1 time");
},
arg: " yesterday",
status: "VALID",
message: ""
},
d2: {
value: function (d2) {
var compare = new Date().getTime() + (24 * 60 * 60 * 1000);
// See comment for d1 in the test for 'tsdate now today'
assert.ok(d2.getTime() - compare < 30 * 1000,
"d2 time");
},
arg: " tomorrow",
status: "VALID",
message: ""
},
}
},
exec: {
output: [ /^Exec: tsdate/, new Date().getFullYear() ],
type: "testCommandOutput",
error: false
}
}
]);
};
exports.testIncrDecr = function (options) {
return helpers.audit(options, [
{
// createRequisitionAutomator doesn't fake UP/DOWN well enough
skipRemainingIf: options.isNode,
setup: "tsdate 2001-01-01<UP>",
check: {
input: "tsdate 2001-01-02",
hints: " <d2>",
markup: "VVVVVVVVVVVVVVVVV",
status: "ERROR",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
assert.is(d1.getFullYear(), 2001, "d1 year");
assert.is(d1.getMonth(), 0, "d1 month");
assert.is(d1.getDate(), 2, "d1 date");
assert.is(d1.getHours(), 0, "d1 hours");
assert.is(d1.getMinutes(), 0, "d1 minutes");
assert.is(d1.getSeconds(), 0, "d1 seconds");
assert.is(d1.getMilliseconds(), 0, "d1 millis");
},
arg: " 2001-01-02",
status: "VALID",
message: ""
},
d2: {
value: undefined,
status: "INCOMPLETE"
},
}
}
},
{
// Check wrapping on decrement
setup: "tsdate 2001-02-01<DOWN>",
check: {
input: "tsdate 2001-01-31",
hints: " <d2>",
markup: "VVVVVVVVVVVVVVVVV",
status: "ERROR",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
assert.is(d1.getFullYear(), 2001, "d1 year");
assert.is(d1.getMonth(), 0, "d1 month");
assert.is(d1.getDate(), 31, "d1 date");
assert.is(d1.getHours(), 0, "d1 hours");
assert.is(d1.getMinutes(), 0, "d1 minutes");
assert.is(d1.getSeconds(), 0, "d1 seconds");
assert.is(d1.getMilliseconds(), 0, "d1 millis");
},
arg: " 2001-01-31",
status: "VALID",
message: ""
},
d2: {
value: undefined,
status: "INCOMPLETE"
},
}
}
},
{
// Check 'max' value capping on increment
setup: 'tsdate 2001-02-01 "27 feb 2000"<UP>',
check: {
input: 'tsdate 2001-02-01 "2000-02-28"',
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsdate" },
d1: {
value: function (d1) {
assert.is(d1.getFullYear(), 2001, "d1 year");
assert.is(d1.getMonth(), 1, "d1 month");
assert.is(d1.getDate(), 1, "d1 date");
assert.is(d1.getHours(), 0, "d1 hours");
assert.is(d1.getMinutes(), 0, "d1 minutes");
assert.is(d1.getSeconds(), 0, "d1 seconds");
assert.is(d1.getMilliseconds(), 0, "d1 millis");
},
arg: " 2001-02-01",
status: "VALID",
message: ""
},
d2: {
value: function (d2) {
assert.is(d2.getFullYear(), 2000, "d2 year");
assert.is(d2.getMonth(), 1, "d2 month");
assert.is(d2.getDate(), 28, "d2 date");
assert.is(d2.getHours(), 0, "d2 hours");
assert.is(d2.getMinutes(), 0, "d2 minutes");
assert.is(d2.getSeconds(), 0, "d2 seconds");
assert.is(d2.getMilliseconds(), 0, "d2 millis");
},
arg: ' "2000-02-28"',
status: "VALID",
message: ""
},
}
}
}
]);
};

View file

@ -0,0 +1,656 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_exec.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
exports.testParamGroup = function (options) {
var tsg = options.requisition.system.commands.get("tsg");
assert.is(tsg.params[0].groupName, null, "tsg param 0 group null");
assert.is(tsg.params[1].groupName, "First", "tsg param 1 group First");
assert.is(tsg.params[2].groupName, "First", "tsg param 2 group First");
assert.is(tsg.params[3].groupName, "Second", "tsg param 3 group Second");
assert.is(tsg.params[4].groupName, "Second", "tsg param 4 group Second");
};
exports.testWithHelpers = function (options) {
return helpers.audit(options, [
{
setup: "tss",
check: {
input: "tss",
hints: "",
markup: "VVV",
cursor: 3,
current: "__command",
status: "VALID",
unassigned: [ ],
args: {
command: { name: "tss" },
}
},
exec: {
output: /^Exec: tss/,
}
},
{
setup: "tsv option1 10",
check: {
input: "tsv option1 10",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "optionValue",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: "string",
arg: " option1",
status: "VALID",
message: ""
},
optionValue: {
arg: " 10",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsv optionType=option1 optionValue=10"
}
},
{
setup: "tsv option2 10",
check: {
input: "tsv option2 10",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "optionValue",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsv" },
optionType: {
value: "number",
arg: " option2",
status: "VALID",
message: ""
},
optionValue: {
arg: " 10",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsv optionType=option2 optionValue=10"
}
},
// Delegated remote types can't transfer value types so we only test for
// the value of optionValue when we're local
{
skipIf: options.isRemote,
setup: "tsv option1 10",
check: {
args: { optionValue: { value: "10" } }
},
exec: {
output: "Exec: tsv optionType=option1 optionValue=10"
}
},
{
skipIf: options.isRemote,
setup: "tsv option2 10",
check: {
args: { optionValue: { value: 10 } }
},
exec: {
output: "Exec: tsv optionType=option2 optionValue=10"
}
}
]);
};
exports.testExecText = function (options) {
return helpers.audit(options, [
{
setup: "tsr fred",
check: {
input: "tsr fred",
hints: "",
markup: "VVVVVVVV",
cursor: 8,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "fred",
arg: " fred",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsr text=fred"
}
},
{
setup: "tsr fred bloggs",
check: {
input: "tsr fred bloggs",
hints: "",
markup: "VVVVVVVVVVVVVVV",
cursor: 15,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "fred bloggs",
arg: " fred bloggs",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsr text=fred\\ bloggs"
}
},
{
setup: 'tsr "fred bloggs"',
check: {
input: 'tsr "fred bloggs"',
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "fred bloggs",
arg: ' "fred bloggs"',
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsr text=fred\\ bloggs"
}
},
{
setup: 'tsr "fred bloggs',
check: {
input: 'tsr "fred bloggs',
hints: "",
markup: "VVVVVVVVVVVVVVVV",
cursor: 16,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsr" },
text: {
value: "fred bloggs",
arg: ' "fred bloggs',
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsr text=fred\\ bloggs"
}
}
]);
};
exports.testExecBoolean = function (options) {
return helpers.audit(options, [
{
setup: "tsb",
check: {
input: "tsb",
hints: " [toggle]",
markup: "VVV",
cursor: 3,
current: "__command",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsb" },
toggle: {
value: false,
arg: "",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsb toggle=false"
}
},
{
setup: "tsb --toggle",
check: {
input: "tsb --toggle",
hints: "",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "toggle",
status: "VALID",
predictions: [ ],
unassigned: [ ],
outputState: "false:default",
args: {
command: { name: "tsb" },
toggle: {
value: true,
arg: " --toggle",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsb toggle=true"
}
}
]);
};
exports.testExecNumber = function (options) {
return helpers.audit(options, [
{
setup: "tsu 10",
check: {
input: "tsu 10",
hints: "",
markup: "VVVVVV",
cursor: 6,
current: "num",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: { value: 10, arg: " 10", status: "VALID", message: "" }
}
},
exec: {
output: "Exec: tsu num=10"
}
},
{
setup: "tsu --num 10",
check: {
input: "tsu --num 10",
hints: "",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "num",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsu" },
num: { value: 10, arg: " --num 10", status: "VALID", message: "" }
}
},
exec: {
output: "Exec: tsu num=10"
}
}
]);
};
exports.testExecScript = function (options) {
return helpers.audit(options, [
{
// Bug 704829 - Enable GCLI Javascript parameters
// The answer to this should be 2
setup: "tsj { 1 + 1 }",
check: {
input: "tsj { 1 + 1 }",
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsj" },
javascript: {
arg: " { 1 + 1 }",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Exec: tsj javascript=1 + 1"
}
}
]);
};
exports.testExecNode = function (options) {
return helpers.audit(options, [
{
skipIf: options.isRemote,
setup: "tse :root",
check: {
input: "tse :root",
hints: " [options]",
markup: "VVVVVVVVV",
cursor: 9,
current: "node",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tse" },
node: {
arg: " :root",
status: "VALID",
message: ""
},
nodes: {
arg: "",
status: "VALID",
message: ""
},
nodes2: {
arg: "",
status: "VALID",
message: ""
}
}
},
exec: {
output: /^Exec: tse/
},
post: function (output) {
assert.is(output.data.args.node, ":root", "node should be :root");
assert.is(output.data.args.nodes, "Error", "nodes should be Error");
assert.is(output.data.args.nodes2, "Error", "nodes2 should be Error");
}
}
]);
};
exports.testExecSubCommand = function (options) {
return helpers.audit(options, [
{
setup: "tsn dif fred",
check: {
input: "tsn dif fred",
hints: "",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn dif" },
text: { value: "fred", arg: " fred", status: "VALID", message: "" }
}
},
exec: {
output: "Exec: tsnDif text=fred"
}
},
{
setup: "tsn exten fred",
check: {
input: "tsn exten fred",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn exten" },
text: { value: "fred", arg: " fred", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tsnExten text=fred"
}
},
{
setup: "tsn extend fred",
check: {
input: "tsn extend fred",
hints: "",
markup: "VVVVVVVVVVVVVVV",
cursor: 15,
current: "text",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsn extend" },
text: { value: "fred", arg: " fred", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tsnExtend text=fred"
}
}
]);
};
exports.testExecArray = function (options) {
return helpers.audit(options, [
{
setup: "tselarr 1",
check: {
input: "tselarr 1",
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "num",
status: "VALID",
predictions: ["1"],
unassigned: [ ],
outputState: "false:default",
args: {
command: { name: "tselarr" },
num: { value: "1", arg: " 1", status: "VALID", message: "" },
arr: { /* value:,*/ arg: "{}", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tselarr num=1 arr="
}
},
{
setup: "tselarr 1 a",
check: {
input: "tselarr 1 a",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "arr",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tselarr" },
num: { value: "1", arg: " 1", status: "VALID", message: "" },
arr: { /* value:a,*/ arg: "{ a}", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tselarr num=1 arr=a"
}
},
{
setup: "tselarr 1 a b",
check: {
input: "tselarr 1 a b",
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "arr",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tselarr" },
num: { value: "1", arg: " 1", status: "VALID", message: "" },
arr: { /* value:a,b,*/ arg: "{ a, b}", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tselarr num=1 arr=a b"
}
}
]);
};
exports.testExecMultiple = function (options) {
return helpers.audit(options, [
{
setup: "tsm a 10 10",
check: {
input: "tsm a 10 10",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "num",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tsm" },
abc: { value: "a", arg: " a", status: "VALID", message: "" },
txt: { value: "10", arg: " 10", status: "VALID", message: "" },
num: { value: 10, arg: " 10", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tsm abc=a txt=10 num=10"
}
}
]);
};
exports.testExecDefaults = function (options) {
return helpers.audit(options, [
{
// Bug 707009 - GCLI doesn't always fill in default parameters properly
setup: "tsg aaa",
check: {
input: "tsg aaa",
hints: " [options]",
markup: "VVVVVVV",
cursor: 7,
current: "solo",
status: "VALID",
predictions: ["aaa"],
unassigned: [ ],
args: {
command: { name: "tsg" },
solo: { value: "aaa", arg: " aaa", status: "VALID", message: "" },
txt1: { value: undefined, arg: "", status: "VALID", message: "" },
bool: { value: false, arg: "", status: "VALID", message: "" },
txt2: { value: undefined, arg: "", status: "VALID", message: "" },
num: { value: undefined, arg: "", status: "VALID", message: "" },
}
},
exec: {
output: "Exec: tsg solo=aaa txt1= bool=false txt2=d num=42"
}
}
]);
};
exports.testNested = function (options) {
var commands = options.requisition.system.commands;
commands.add({
name: "nestorama",
exec: function (args, context) {
return context.updateExec("tsb").then(function (tsbOutput) {
return context.updateExec("tsu 6").then(function (tsuOutput) {
return JSON.stringify({
tsb: tsbOutput.data,
tsu: tsuOutput.data
});
});
});
}
});
return helpers.audit(options, [
{
setup: "nestorama",
exec: {
output:
"{" +
'"tsb":{' +
'"name":"tsb",' +
'"args":{"toggle":"false"}' +
"}," +
'"tsu":{' +
'"name":"tsu",' +
'"args":{"num":"6"}' +
"}" +
"}"
},
post: function () {
commands.remove("nestorama");
}
}
]);
};

View file

@ -0,0 +1,73 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_fail.js");
}
// var helpers = require('./helpers');
exports.testBasic = function (options) {
return helpers.audit(options, [
{
setup: "tsfail reject",
exec: {
output: "rejected promise",
type: "error",
error: true
}
},
{
setup: "tsfail rejecttyped",
exec: {
output: "54",
type: "number",
error: true
}
},
{
setup: "tsfail throwerror",
exec: {
output: /thrown error$/,
type: "error",
error: true
}
},
{
setup: "tsfail throwstring",
exec: {
output: "thrown string",
type: "error",
error: true
}
},
{
setup: "tsfail noerror",
exec: {
output: "no error",
type: "string",
error: false
}
}
]);
};

View file

@ -0,0 +1,821 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_file.js");
}
// var helpers = require('./helpers');
var local = false;
exports.testBasic = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.isFirefox, // No file implementation in Firefox
setup: "tsfile open /",
check: {
input: "tsfile open /",
hints: "",
markup: "VVVVVVVVVVVVI",
cursor: 13,
current: "p1",
status: "ERROR",
message: "'/' is not a file",
args: {
command: { name: "tsfile open" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' is not a file"
}
}
}
},
{
setup: "tsfile open /zxcv",
check: {
input: "tsfile open /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVIIIII",
cursor: 17,
current: "p1",
status: "ERROR",
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile open" },
p1: {
value: undefined,
arg: " /zxcv",
status: "INCOMPLETE",
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: !local,
setup: "tsfile open /mach_kernel",
check: {
input: "tsfile open /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 24,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile open" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile saveas /",
check: {
input: "tsfile saveas /",
hints: "",
markup: "VVVVVVVVVVVVVVI",
cursor: 15,
current: "p1",
status: "ERROR",
message: "'/' already exists",
args: {
command: { name: "tsfile saveas" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' already exists"
}
}
}
},
{
setup: "tsfile saveas /zxcv",
check: {
input: "tsfile saveas /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVVVVVVVV",
cursor: 19,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile saveas" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile saveas /mach_kernel",
check: {
input: "tsfile saveas /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVIIIIIIIIIIII",
cursor: 26,
current: "p1",
status: "ERROR",
message: "'/mach_kernel' already exists",
args: {
command: { name: "tsfile saveas" },
p1: {
value: undefined,
arg: " /mach_kernel",
status: "INCOMPLETE",
message: "'/mach_kernel' already exists"
}
}
}
},
{
setup: "tsfile save /",
check: {
input: "tsfile save /",
hints: "",
markup: "VVVVVVVVVVVVI",
cursor: 13,
current: "p1",
status: "ERROR",
message: "'/' is not a file",
args: {
command: { name: "tsfile save" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' is not a file"
}
}
}
},
{
setup: "tsfile save /zxcv",
check: {
input: "tsfile save /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile save" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile save /mach_kernel",
check: {
input: "tsfile save /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 24,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile save" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile cd /",
check: {
input: "tsfile cd /",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile cd" },
p1: {
value: "/",
arg: " /",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile cd /zxcv",
check: {
input: "tsfile cd /zxcv",
// hints: ' -> /dev/',
markup: "VVVVVVVVVVIIIII",
cursor: 15,
current: "p1",
status: "ERROR",
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile cd" },
p1: {
value: undefined,
arg: " /zxcv",
status: "INCOMPLETE",
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: true || !local,
setup: "tsfile cd /etc/passwd",
check: {
input: "tsfile cd /etc/passwd",
hints: " -> /etc/pam.d/",
markup: "VVVVVVVVVVIIIIIIIIIII",
cursor: 21,
current: "p1",
status: "ERROR",
message: "'/etc/passwd' is not a directory",
args: {
command: { name: "tsfile cd" },
p1: {
value: undefined,
arg: " /etc/passwd",
status: "INCOMPLETE",
message: "'/etc/passwd' is not a directory"
}
}
}
},
{
setup: "tsfile mkdir /",
check: {
input: "tsfile mkdir /",
hints: "",
markup: "VVVVVVVVVVVVVI",
cursor: 14,
current: "p1",
status: "ERROR",
message: "" / " already exists",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' already exists"
}
}
}
},
{
setup: "tsfile mkdir /zxcv",
check: {
input: "tsfile mkdir /zxcv",
// hints: ' -> /dev/',
markup: "VVVVVVVVVVVVVVVVVV",
cursor: 18,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile mkdir /mach_kernel",
check: {
input: "tsfile mkdir /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVIIIIIIIIIIII",
cursor: 25,
current: "p1",
status: "ERROR",
message: "'/mach_kernel' already exists",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: undefined,
arg: " /mach_kernel",
status: "INCOMPLETE",
message: "'/mach_kernel' already exists"
}
}
}
},
{
setup: "tsfile rm /",
check: {
input: "tsfile rm /",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile rm" },
p1: {
value: "/",
arg: " /",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile rm /zxcv",
check: {
input: "tsfile rm /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVIIIII",
cursor: 15,
current: "p1",
status: "ERROR",
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile rm" },
p1: {
value: undefined,
arg: " /zxcv",
status: "INCOMPLETE",
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: !local,
setup: "tsfile rm /mach_kernel",
check: {
input: "tsfile rm /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVV",
cursor: 22,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile rm" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testFirefoxBasic = function (options) {
return helpers.audit(options, [
{
// These tests are just like the ones above tailored for running in
// Firefox
skipRemainingIf: true,
// skipRemainingIf: !options.isFirefox,
skipIf: true,
setup: "tsfile open /",
check: {
input: "tsfile open /",
hints: "",
markup: "VVVVVVVVVVVVI",
cursor: 13,
current: "p1",
status: "ERROR",
message: "'/' is not a file",
args: {
command: { name: "tsfile open" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' is not a file"
}
}
}
},
{
skipIf: true,
setup: "tsfile open /zxcv",
check: {
input: "tsfile open /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVIIIII",
cursor: 17,
current: "p1",
status: "ERROR",
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile open" },
p1: {
value: undefined,
arg: " /zxcv",
status: "INCOMPLETE",
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: !local,
setup: "tsfile open /mach_kernel",
check: {
input: "tsfile open /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 24,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile open" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: true,
setup: "tsfile saveas /",
check: {
input: "tsfile saveas /",
hints: "",
markup: "VVVVVVVVVVVVVVI",
cursor: 15,
current: "p1",
status: "ERROR",
message: "'/' already exists",
args: {
command: { name: "tsfile saveas" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' already exists"
}
}
}
},
{
skipIf: true,
setup: "tsfile saveas /zxcv",
check: {
input: "tsfile saveas /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVVVVVVVV",
cursor: 19,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile saveas" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile saveas /mach_kernel",
check: {
input: "tsfile saveas /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVIIIIIIIIIIII",
cursor: 26,
current: "p1",
status: "ERROR",
message: "'/mach_kernel' already exists",
args: {
command: { name: "tsfile saveas" },
p1: {
value: undefined,
arg: " /mach_kernel",
status: "INCOMPLETE",
message: "'/mach_kernel' already exists"
}
}
}
},
{
skipIf: true,
setup: "tsfile save /",
check: {
input: "tsfile save /",
hints: "",
markup: "VVVVVVVVVVVVI",
cursor: 13,
current: "p1",
status: "ERROR",
message: "'/' is not a file",
args: {
command: { name: "tsfile save" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' is not a file"
}
}
}
},
{
skipIf: true,
setup: "tsfile save /zxcv",
check: {
input: "tsfile save /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile save" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile save /mach_kernel",
check: {
input: "tsfile save /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 24,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile save" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile cd /",
check: {
input: "tsfile cd /",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile cd" },
p1: {
value: "/",
arg: " /",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tsfile cd /zxcv",
check: {
input: "tsfile cd /zxcv",
// hints: ' -> /dev/',
// markup: 'VVVVVVVVVVIIIII',
cursor: 15,
current: "p1",
// status: 'ERROR',
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile cd" },
p1: {
value: undefined,
arg: " /zxcv",
// status: 'INCOMPLETE',
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: true || !local,
setup: "tsfile cd /etc/passwd",
check: {
input: "tsfile cd /etc/passwd",
hints: " -> /etc/pam.d/",
markup: "VVVVVVVVVVIIIIIIIIIII",
cursor: 21,
current: "p1",
status: "ERROR",
message: "'/etc/passwd' is not a directory",
args: {
command: { name: "tsfile cd" },
p1: {
value: undefined,
arg: " /etc/passwd",
status: "INCOMPLETE",
message: "'/etc/passwd' is not a directory"
}
}
}
},
{
setup: "tsfile mkdir /",
check: {
input: "tsfile mkdir /",
hints: "",
markup: "VVVVVVVVVVVVVI",
cursor: 14,
current: "p1",
status: "ERROR",
message: "" / " already exists",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: undefined,
arg: " /",
status: "INCOMPLETE",
message: "'/' already exists"
}
}
}
},
{
setup: "tsfile mkdir /zxcv",
check: {
input: "tsfile mkdir /zxcv",
// hints: ' -> /dev/',
markup: "VVVVVVVVVVVVVVVVVV",
cursor: 18,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: "/zxcv",
arg: " /zxcv",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: !local,
setup: "tsfile mkdir /mach_kernel",
check: {
input: "tsfile mkdir /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVIIIIIIIIIIII",
cursor: 25,
current: "p1",
status: "ERROR",
message: "'/mach_kernel' already exists",
args: {
command: { name: "tsfile mkdir" },
p1: {
value: undefined,
arg: " /mach_kernel",
status: "INCOMPLETE",
message: "'/mach_kernel' already exists"
}
}
}
},
{
skipIf: true,
setup: "tsfile rm /",
check: {
input: "tsfile rm /",
hints: "",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile rm" },
p1: {
value: "/",
arg: " /",
status: "VALID",
message: ""
}
}
}
},
{
skipIf: true,
setup: "tsfile rm /zxcv",
check: {
input: "tsfile rm /zxcv",
// hints: ' -> /etc/',
markup: "VVVVVVVVVVIIIII",
cursor: 15,
current: "p1",
status: "ERROR",
message: "'/zxcv' doesn't exist",
args: {
command: { name: "tsfile rm" },
p1: {
value: undefined,
arg: " /zxcv",
status: "INCOMPLETE",
message: "'/zxcv' doesn't exist"
}
}
}
},
{
skipIf: !local,
setup: "tsfile rm /mach_kernel",
check: {
input: "tsfile rm /mach_kernel",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVV",
cursor: 22,
current: "p1",
status: "VALID",
message: "",
args: {
command: { name: "tsfile rm" },
p1: {
value: "/mach_kernel",
arg: " /mach_kernel",
status: "VALID",
message: ""
}
}
}
}
]);
};

View file

@ -0,0 +1,46 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_fileparser.js");
}
// var assert = require('../testharness/assert');
var fileparser = require("gcli/util/fileparser");
var local = false;
exports.testGetPredictor = function (options) {
if (!options.isNode || !local) {
assert.log("Skipping tests due to install differences.");
return;
}
var opts = { filetype: "file", existing: "yes" };
var predictor = fileparser.getPredictor("/usr/locl/bin/nmp", opts);
return predictor().then(function (replies) {
assert.is(replies[0].name,
"/usr/local/bin/npm",
"predict npm");
});
};

View file

@ -0,0 +1,66 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_filesystem.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
var filesystem = require("gcli/util/filesystem");
exports.testSplit = function (options) {
if (!options.isNode) {
return;
}
helpers.arrayIs(filesystem.split("", "/"),
[ "." ],
"split <blank>");
helpers.arrayIs(filesystem.split("a", "/"),
[ "a" ],
"split a");
helpers.arrayIs(filesystem.split("a/b/c", "/"),
[ "a", "b", "c" ],
"split a/b/c");
helpers.arrayIs(filesystem.split("/a/b/c/", "/"),
[ "a", "b", "c" ],
"split a/b/c");
helpers.arrayIs(filesystem.split("/a/b///c/", "/"),
[ "a", "b", "c" ],
"split a/b/c");
};
exports.testJoin = function (options) {
if (!options.isNode) {
return;
}
assert.is(filesystem.join("usr", "local", "bin"),
"usr/local/bin",
"join to usr/local/bin");
};

View file

@ -0,0 +1,67 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_focus.js");
}
// var helpers = require('./helpers');
exports.testBasic = function (options) {
return helpers.audit(options, [
{
name: "exec setup",
setup: function () {
// Just check that we've got focus, and everything is clear
helpers.focusInput(options);
return helpers.setInput(options, "echo hi");
},
check: { },
exec: { }
},
{
setup: "tsn deep",
check: {
input: "tsn deep",
hints: " down nested cmd",
markup: "IIIVIIII",
cursor: 8,
status: "ERROR",
outputState: "false:default",
tooltipState: "false:default"
}
},
{
setup: "tsn deep<TAB>",
check: {
input: "tsn deep down nested cmd ",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVV",
cursor: 25,
status: "VALID",
outputState: "false:default",
tooltipState: "false:default"
}
}
]);
};

View file

@ -0,0 +1,72 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_history.js");
}
// var assert = require('../testharness/assert');
var History = require("gcli/ui/history").History;
exports.testSimpleHistory = function (options) {
var history = new History({});
history.add("foo");
history.add("bar");
assert.is(history.backward(), "bar");
assert.is(history.backward(), "foo");
// Adding to the history again moves us back to the start of the history.
history.add("quux");
assert.is(history.backward(), "quux");
assert.is(history.backward(), "bar");
assert.is(history.backward(), "foo");
};
exports.testBackwardsPastIndex = function (options) {
var history = new History({});
history.add("foo");
history.add("bar");
assert.is(history.backward(), "bar");
assert.is(history.backward(), "foo");
// Moving backwards past recorded history just keeps giving you the last
// item.
assert.is(history.backward(), "foo");
};
exports.testForwardsPastIndex = function (options) {
var history = new History({});
history.add("foo");
history.add("bar");
assert.is(history.backward(), "bar");
assert.is(history.backward(), "foo");
// Going forward through the history again.
assert.is(history.forward(), "bar");
// 'Present' time.
assert.is(history.forward(), "");
// Going to the 'future' just keeps giving us the empty string.
assert.is(history.forward(), "");
};

View file

@ -0,0 +1,439 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_incomplete.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
exports.testBasic = function (options) {
return helpers.audit(options, [
{
setup: "tsu 2 extra",
check: {
args: {
num: { value: 2, type: "Argument" }
}
},
post: function () {
var requisition = options.requisition;
assert.is(requisition._unassigned.length,
1,
"single unassigned: tsu 2 extra");
assert.is(requisition._unassigned[0].param.type.isIncompleteName,
false,
"unassigned.isIncompleteName: tsu 2 extra");
}
},
{
setup: "tsu",
check: {
args: {
num: { value: undefined, type: "BlankArgument" }
}
}
},
{
setup: "tsg",
check: {
args: {
solo: { type: "BlankArgument" },
txt1: { type: "BlankArgument" },
bool: { type: "BlankArgument" },
txt2: { type: "BlankArgument" },
num: { type: "BlankArgument" }
}
}
}
]);
};
exports.testCompleted = function (options) {
return helpers.audit(options, [
{
setup: "tsela<TAB>",
check: {
args: {
command: { name: "tselarr", type: "Argument" },
num: { type: "BlankArgument" },
arr: { type: "ArrayArgument" }
}
}
},
{
setup: "tsn dif ",
check: {
input: "tsn dif ",
hints: "<text>",
markup: "VVVVVVVV",
cursor: 8,
status: "ERROR",
args: {
command: { name: "tsn dif", type: "MergedArgument" },
text: { type: "BlankArgument", status: "INCOMPLETE" }
}
}
},
{
setup: "tsn di<TAB>",
check: {
input: "tsn dif ",
hints: "<text>",
markup: "VVVVVVVV",
cursor: 8,
status: "ERROR",
args: {
command: { name: "tsn dif", type: "Argument" },
text: { type: "BlankArgument", status: "INCOMPLETE" }
}
}
},
// The above 2 tests take different routes to 'tsn dif '.
// The results should be similar. The difference is in args.command.type.
{
setup: "tsg -",
check: {
input: "tsg -",
hints: "-txt1 <solo> [options]",
markup: "VVVVI",
cursor: 5,
status: "ERROR",
args: {
solo: { value: undefined, status: "INCOMPLETE" },
txt1: { value: undefined, status: "VALID" },
bool: { value: false, status: "VALID" },
txt2: { value: undefined, status: "VALID" },
num: { value: undefined, status: "VALID" }
}
}
},
{
setup: "tsg -<TAB>",
check: {
input: "tsg --txt1 ",
hints: "<string> <solo> [options]",
markup: "VVVVIIIIIIV",
cursor: 11,
status: "ERROR",
args: {
solo: { value: undefined, status: "INCOMPLETE" },
txt1: { value: undefined, status: "INCOMPLETE" },
bool: { value: false, status: "VALID" },
txt2: { value: undefined, status: "VALID" },
num: { value: undefined, status: "VALID" }
}
}
},
{
setup: "tsg --txt1 fred",
check: {
input: "tsg --txt1 fred",
hints: " <solo> [options]",
markup: "VVVVVVVVVVVVVVV",
status: "ERROR",
args: {
solo: { value: undefined, status: "INCOMPLETE" },
txt1: { value: "fred", status: "VALID" },
bool: { value: false, status: "VALID" },
txt2: { value: undefined, status: "VALID" },
num: { value: undefined, status: "VALID" }
}
}
},
{
setup: "tscook key value --path path --",
check: {
input: "tscook key value --path path --",
hints: "domain [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVII",
status: "ERROR",
args: {
key: { value: "key", status: "VALID" },
value: { value: "value", status: "VALID" },
path: { value: "path", status: "VALID" },
domain: { value: undefined, status: "VALID" },
secure: { value: false, status: "VALID" }
}
}
},
{
setup: "tscook key value --path path --domain domain --",
check: {
input: "tscook key value --path path --domain domain --",
hints: "secure [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVII",
status: "ERROR",
args: {
key: { value: "key", status: "VALID" },
value: { value: "value", status: "VALID" },
path: { value: "path", status: "VALID" },
domain: { value: "domain", status: "VALID" },
secure: { value: false, status: "VALID" }
}
}
}
]);
};
exports.testCase = function (options) {
return helpers.audit(options, [
{
setup: "tsg AA",
check: {
input: "tsg AA",
hints: " [options] -> aaa",
markup: "VVVVII",
status: "ERROR",
args: {
solo: { value: undefined, text: "AA", status: "INCOMPLETE" },
txt1: { value: undefined, status: "VALID" },
bool: { value: false, status: "VALID" },
txt2: { value: undefined, status: "VALID" },
num: { value: undefined, status: "VALID" }
}
}
}
]);
};
exports.testIncomplete = function (options) {
return helpers.audit(options, [
{
setup: "tsm a a -",
check: {
args: {
abc: { value: "a", type: "Argument" },
txt: { value: "a", type: "Argument" },
num: { value: undefined, arg: " -", type: "Argument", status: "INCOMPLETE" }
}
}
},
{
setup: "tsg -",
check: {
args: {
solo: { type: "BlankArgument" },
txt1: { type: "BlankArgument" },
bool: { type: "BlankArgument" },
txt2: { type: "BlankArgument" },
num: { type: "BlankArgument" }
}
},
post: function () {
var requisition = options.requisition;
assert.is(requisition._unassigned[0],
requisition.getAssignmentAt(5),
"unassigned -");
assert.is(requisition._unassigned.length,
1,
"single unassigned - tsg -");
assert.is(requisition._unassigned[0].param.type.isIncompleteName,
true,
"unassigned.isIncompleteName: tsg -");
}
}
]);
};
exports.testRepeated = function (options) {
return helpers.audit(options, [
{
setup: "tscook key value --path jjj --path kkk",
check: {
input: "tscook key value --path jjj --path kkk",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVEEEEEEVEEE",
cursor: 38,
current: "__unassigned",
status: "ERROR",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ " --path", " kkk" ],
args: {
command: { name: "tscook" },
key: {
value: "key",
arg: " key",
status: "VALID",
message: ""
},
value: {
value: "value",
arg: " value",
status: "VALID",
message: ""
},
path: {
value: "jjj",
arg: " --path jjj",
status: "VALID",
message: ""
},
domain: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
secure: {
value: false,
arg: "",
status: "VALID",
message: ""
},
}
}
}
]);
};
exports.testHidden = function (options) {
return helpers.audit(options, [
{
setup: "tshidde",
check: {
input: "tshidde",
hints: " -> tse",
status: "ERROR"
}
},
{
setup: "tshidden",
check: {
input: "tshidden",
hints: " [options]",
markup: "VVVVVVVV",
status: "VALID",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --vis",
check: {
input: "tshidden --vis",
hints: "ible [options]",
markup: "VVVVVVVVVIIIII",
status: "ERROR",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --invisiblestrin",
check: {
input: "tshidden --invisiblestrin",
hints: " [options]",
markup: "VVVVVVVVVEEEEEEEEEEEEEEEE",
status: "ERROR",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --invisiblestring",
check: {
input: "tshidden --invisiblestring",
hints: " <string> [options]",
markup: "VVVVVVVVVIIIIIIIIIIIIIIIII",
status: "ERROR",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "INCOMPLETE" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --invisiblestring x",
check: {
input: "tshidden --invisiblestring x",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: "x", status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --invisibleboolea",
check: {
input: "tshidden --invisibleboolea",
hints: " [options]",
markup: "VVVVVVVVVEEEEEEEEEEEEEEEEE",
status: "ERROR",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
},
{
setup: "tshidden --invisibleboolean",
check: {
input: "tshidden --invisibleboolean",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
visible: { value: undefined, status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: true, status: "VALID" }
}
}
},
{
setup: "tshidden --visible xxx",
check: {
input: "tshidden --visible xxx",
markup: "VVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
hints: "",
args: {
visible: { value: "xxx", status: "VALID" },
invisiblestring: { value: undefined, status: "VALID" },
invisibleboolean: { value: false, status: "VALID" }
}
}
}
]);
};

View file

@ -0,0 +1,97 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_inputter.js");
}
// var assert = require('../testharness/assert');
var KeyEvent = require("gcli/util/util").KeyEvent;
var latestEvent;
var latestData;
var outputted = function (ev) {
latestEvent = ev;
ev.output.promise.then(function () {
latestData = ev.output.data;
});
};
exports.setup = function (options) {
options.requisition.commandOutputManager.onOutput.add(outputted);
};
exports.shutdown = function (options) {
options.requisition.commandOutputManager.onOutput.remove(outputted);
};
exports.testOutput = function (options) {
latestEvent = undefined;
latestData = undefined;
var terminal = options.terminal;
if (!terminal) {
assert.log("Skipping testInputter.testOutput due to lack of terminal.");
return;
}
var focusManager = terminal.focusManager;
terminal.setInput("tss");
var ev0 = { keyCode: KeyEvent.DOM_VK_RETURN };
terminal.onKeyDown(ev0);
assert.is(terminal.getInputState().typed,
"tss",
"terminal should do nothing on RETURN keyDown");
assert.is(latestEvent, undefined, "no events this test");
assert.is(latestData, undefined, "no data this test");
var ev1 = { keyCode: KeyEvent.DOM_VK_RETURN };
return terminal.handleKeyUp(ev1).then(function () {
assert.ok(latestEvent != null, "events this test");
assert.is(latestData.name, "tss", "last command is tss");
assert.is(terminal.getInputState().typed,
"",
"terminal should exec on RETURN keyUp");
assert.ok(focusManager._recentOutput, "recent output happened");
var ev2 = { keyCode: KeyEvent.DOM_VK_F1 };
return terminal.handleKeyUp(ev2).then(function () {
assert.ok(!focusManager._recentOutput, "no recent output happened post F1");
assert.ok(focusManager._helpRequested, "F1 = help");
var ev3 = { keyCode: KeyEvent.DOM_VK_ESCAPE };
return terminal.handleKeyUp(ev3).then(function () {
assert.ok(!focusManager._helpRequested, "ESCAPE = anti help");
});
});
});
};

View file

@ -0,0 +1,71 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_intro.js");
}
// var helpers = require('./helpers');
exports.testIntroStatus = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: function commandIntroMissing() {
return options.requisition.system.commands.get("intro") == null;
},
setup: "intro",
check: {
typed: "intro",
markup: "VVVVV",
status: "VALID",
hints: ""
}
},
{
setup: "intro foo",
check: {
typed: "intro foo",
markup: "VVVVVVEEE",
status: "ERROR",
hints: ""
}
},
{
setup: "intro",
check: {
typed: "intro",
markup: "VVVVV",
status: "VALID",
hints: ""
},
exec: {
output: [
/command\s*line/,
/help/,
/F1/,
/Escape/
]
}
}
]);
};

View file

@ -0,0 +1,570 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_js.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
exports.setup = function (options) {
if (jsTestDisallowed(options)) {
return;
}
// Check that we're not trespassing on 'donteval'
var win = options.requisition.environment.window;
Object.defineProperty(win, "donteval", {
get: function () {
assert.ok(false, "donteval should not be used");
console.trace();
return { cant: "", touch: "", "this": "" };
},
enumerable: true,
configurable: true
});
};
exports.shutdown = function (options) {
if (jsTestDisallowed(options)) {
return;
}
delete options.requisition.environment.window.donteval;
};
function jsTestDisallowed(options) {
return options.isRemote || // Altering the environment (which isn't remoted)
options.isNode ||
options.requisition.system.commands.get("{") == null;
}
exports.testBasic = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: jsTestDisallowed,
setup: "{",
check: {
input: "{",
hints: "",
markup: "V",
cursor: 1,
current: "javascript",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: undefined,
arg: "{",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ ",
check: {
input: "{ ",
hints: "",
markup: "VV",
cursor: 2,
current: "javascript",
status: "ERROR",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: undefined,
arg: "{ ",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ w",
check: {
input: "{ w",
hints: "indow",
markup: "VVI",
cursor: 3,
current: "javascript",
status: "ERROR",
predictionsContains: [ "window" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "w",
arg: "{ w",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ windo",
check: {
input: "{ windo",
hints: "w",
markup: "VVIIIII",
cursor: 7,
current: "javascript",
status: "ERROR",
predictions: [ "window" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "windo",
arg: "{ windo",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ window",
check: {
input: "{ window",
hints: "",
markup: "VVVVVVVV",
cursor: 8,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "window",
arg: "{ window",
status: "VALID",
message: ""
}
}
}
},
{
setup: "{ window.do",
check: {
input: "{ window.do",
hints: "cument",
markup: "VVIIIIIIIII",
cursor: 11,
current: "javascript",
status: "ERROR",
predictionsContains: [ "window.document" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "window.do",
arg: "{ window.do",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ window.document.title",
check: {
input: "{ window.document.title",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVV",
cursor: 23,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "window.document.title",
arg: "{ window.document.title",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testDocument = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: jsTestDisallowed,
setup: "{ docu",
check: {
input: "{ docu",
hints: "ment",
markup: "VVIIII",
cursor: 6,
current: "javascript",
status: "ERROR",
predictions: [ "document" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "docu",
arg: "{ docu",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ docu<TAB>",
check: {
input: "{ document",
hints: "",
markup: "VVVVVVVVVV",
cursor: 10,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "document",
arg: "{ document",
status: "VALID",
message: ""
}
}
}
},
{
setup: "{ document.titl",
check: {
input: "{ document.titl",
hints: "e",
markup: "VVIIIIIIIIIIIII",
cursor: 15,
current: "javascript",
status: "ERROR",
predictions: [ "document.title" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "document.titl",
arg: "{ document.titl",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ document.titl<TAB>",
check: {
input: "{ document.title ",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "document.title",
// arg: '{ document.title ',
// Node/JSDom gets this wrong and omits the trailing space. Why?
status: "VALID",
message: ""
}
}
}
},
{
setup: "{ document.title",
check: {
input: "{ document.title",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
cursor: 16,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "document.title",
arg: "{ document.title",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testDonteval = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: true, // Commented out until we fix non-enumerable props
setup: "{ don",
check: {
input: "{ don",
hints: "teval",
markup: "VVIII",
cursor: 5,
current: "javascript",
status: "ERROR",
predictions: [ "donteval" ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "don",
arg: "{ don",
status: "INCOMPLETE"
}
}
}
},
{
setup: "{ donteval",
check: {
input: "{ donteval",
hints: "",
markup: "VVVVVVVVVV",
cursor: 10,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "donteval",
arg: "{ donteval",
status: "VALID",
message: ""
}
}
}
},
/*
// This is a controversial test - technically we can tell that it's an error
// because 'donteval.' is a syntax error, however donteval is unsafe so we
// are playing safe by bailing out early. It's enough of a corner case that
// I don't think it warrants fixing
{
setup: '{ donteval.',
check: {
input: '{ donteval.',
hints: '',
markup: 'VVVVVVVVVVV',
cursor: 11,
current: 'javascript',
status: 'VALID',
predictions: [ ],
unassigned: [ ],
args: {
command: { name: '{' },
javascript: {
value: 'donteval.',
arg: '{ donteval.',
status: 'VALID',
message: ''
}
}
}
},
*/
{
setup: "{ donteval.cant",
check: {
input: "{ donteval.cant",
hints: "",
markup: "VVVVVVVVVVVVVVV",
cursor: 15,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "donteval.cant",
arg: "{ donteval.cant",
status: "VALID",
message: ""
}
}
}
},
{
setup: "{ donteval.xxx",
check: {
input: "{ donteval.xxx",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "javascript",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "{" },
javascript: {
value: "donteval.xxx",
arg: "{ donteval.xxx",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testExec = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: jsTestDisallowed,
setup: "{ 1+1",
check: {
input: "{ 1+1",
hints: "",
markup: "VVVVV",
cursor: 5,
current: "javascript",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
javascript: {
value: "1+1",
arg: "{ 1+1",
status: "VALID",
message: ""
}
}
},
exec: {
output: "2",
type: "number",
error: false
}
},
{
setup: "{ 1+1 }",
check: {
input: "{ 1+1 }",
hints: "",
markup: "VVVVVVV",
cursor: 7,
current: "javascript",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
javascript: {
value: "1+1",
arg: "{ 1+1 }",
status: "VALID",
message: ""
}
}
},
exec: {
output: "2",
type: "number",
error: false
}
},
{
setup: '{ "hello"',
check: {
input: '{ "hello"',
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "javascript",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
javascript: {
value: '"hello"',
arg: '{ "hello"',
status: "VALID",
message: ""
}
}
},
exec: {
output: "hello",
type: "string",
error: false
}
},
{
setup: '{ "hello" + 1',
check: {
input: '{ "hello" + 1',
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "javascript",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
javascript: {
value: '"hello" + 1',
arg: '{ "hello" + 1',
status: "VALID",
message: ""
}
}
},
exec: {
output: "hello1",
type: "string",
error: false
}
}
]);
};

View file

@ -0,0 +1,72 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard1.js");
}
var javascript = require("gcli/types/javascript");
// var helpers = require('./helpers');
exports.testSimple = function (options) {
return helpers.audit(options, [
{
setup: "tsela<TAB>",
check: { input: "tselarr ", cursor: 8 }
},
{
setup: "tsn di<TAB>",
check: { input: "tsn dif ", cursor: 8 }
},
{
setup: "tsg a<TAB>",
check: { input: "tsg aaa ", cursor: 8 }
}
]);
};
exports.testScript = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.isRemote ||
options.requisition.system.commands.get("{") == null,
setup: "{ wind<TAB>",
check: { input: "{ window" }
},
{
setup: "{ window.docum<TAB>",
check: { input: "{ window.document" }
}
]);
};
exports.testJsdom = function (options) {
return helpers.audit(options, [
{
skipIf: options.isRemote ||
options.requisition.system.commands.get("{") == null,
setup: "{ window.document.titl<TAB>",
check: { input: "{ window.document.title " }
}
]);
};

View file

@ -0,0 +1,121 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard2.js");
}
// var helpers = require('./helpers');
exports.testIncr = function (options) {
return helpers.audit(options, [
/*
// We currently refuse to increment/decrement things with a non-valid
// status which makes sense for many cases, and is a decent default.
// However in theory we could do better, these tests are there for then
{
setup: 'tsu -70<UP>',
check: { input: 'tsu -5' }
},
{
setup: 'tsu -7<UP>',
check: { input: 'tsu -5' }
},
{
setup: 'tsu -6<UP>',
check: { input: 'tsu -5' }
},
*/
{
setup: "tsu -5<UP>",
check: { input: "tsu -3" }
},
{
setup: "tsu -4<UP>",
check: { input: "tsu -3" }
},
{
setup: "tsu -3<UP>",
check: { input: "tsu 0" }
},
{
setup: "tsu -2<UP>",
check: { input: "tsu 0" }
},
{
setup: "tsu -1<UP>",
check: { input: "tsu 0" }
},
{
setup: "tsu 0<UP>",
check: { input: "tsu 3" }
},
{
setup: "tsu 1<UP>",
check: { input: "tsu 3" }
},
{
setup: "tsu 2<UP>",
check: { input: "tsu 3" }
},
{
setup: "tsu 3<UP>",
check: { input: "tsu 6" }
},
{
setup: "tsu 4<UP>",
check: { input: "tsu 6" }
},
{
setup: "tsu 5<UP>",
check: { input: "tsu 6" }
},
{
setup: "tsu 6<UP>",
check: { input: "tsu 9" }
},
{
setup: "tsu 7<UP>",
check: { input: "tsu 9" }
},
{
setup: "tsu 8<UP>",
check: { input: "tsu 9" }
},
{
setup: "tsu 9<UP>",
check: { input: "tsu 10" }
},
{
setup: "tsu 10<UP>",
check: { input: "tsu 10" }
}
/*
// See notes above
{
setup: 'tsu 100<UP>',
check: { input: 'tsu 10' }
}
*/
]);
};

View file

@ -0,0 +1,119 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard3.js");
}
// var helpers = require('./helpers');
exports.testDecr = function (options) {
return helpers.audit(options, [
/*
// See notes at top of testIncr in testKeyboard2.js
{
setup: 'tsu -70<DOWN>',
check: { input: 'tsu -5' }
},
{
setup: 'tsu -7<DOWN>',
check: { input: 'tsu -5' }
},
{
setup: 'tsu -6<DOWN>',
check: { input: 'tsu -5' }
},
*/
{
setup: "tsu -5<DOWN>",
check: { input: "tsu -5" }
},
{
setup: "tsu -4<DOWN>",
check: { input: "tsu -5" }
},
{
setup: "tsu -3<DOWN>",
check: { input: "tsu -5" }
},
{
setup: "tsu -2<DOWN>",
check: { input: "tsu -3" }
},
{
setup: "tsu -1<DOWN>",
check: { input: "tsu -3" }
},
{
setup: "tsu 0<DOWN>",
check: { input: "tsu -3" }
},
{
setup: "tsu 1<DOWN>",
check: { input: "tsu 0" }
},
{
setup: "tsu 2<DOWN>",
check: { input: "tsu 0" }
},
{
setup: "tsu 3<DOWN>",
check: { input: "tsu 0" }
},
{
setup: "tsu 4<DOWN>",
check: { input: "tsu 3" }
},
{
setup: "tsu 5<DOWN>",
check: { input: "tsu 3" }
},
{
setup: "tsu 6<DOWN>",
check: { input: "tsu 3" }
},
{
setup: "tsu 7<DOWN>",
check: { input: "tsu 6" }
},
{
setup: "tsu 8<DOWN>",
check: { input: "tsu 6" }
},
{
setup: "tsu 9<DOWN>",
check: { input: "tsu 6" }
},
{
setup: "tsu 10<DOWN>",
check: { input: "tsu 9" }
}
/*
// See notes at top of testIncr
{
setup: 'tsu 100<DOWN>',
check: { input: 'tsu 9' }
}
*/
]);
};

View file

@ -0,0 +1,189 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard4.js");
}
// var helpers = require('./helpers');
exports.testIncrFloat = function (options) {
return helpers.audit(options, [
/*
// See notes at top of testIncr
{
setup: 'tsf -70<UP>',
check: { input: 'tsf -6.5' }
},
*/
{
setup: "tsf -6.5<UP>",
check: { input: "tsf -6" }
},
{
setup: "tsf -6<UP>",
check: { input: "tsf -4.5" }
},
{
setup: "tsf -4.5<UP>",
check: { input: "tsf -3" }
},
{
setup: "tsf -4<UP>",
check: { input: "tsf -3" }
},
{
setup: "tsf -3<UP>",
check: { input: "tsf -1.5" }
},
{
setup: "tsf -1.5<UP>",
check: { input: "tsf 0" }
},
{
setup: "tsf 0<UP>",
check: { input: "tsf 1.5" }
},
{
setup: "tsf 1.5<UP>",
check: { input: "tsf 3" }
},
{
setup: "tsf 2<UP>",
check: { input: "tsf 3" }
},
{
setup: "tsf 3<UP>",
check: { input: "tsf 4.5" }
},
{
setup: "tsf 5<UP>",
check: { input: "tsf 6" }
}
/*
// See notes at top of testIncr
{
setup: 'tsf 100<UP>',
check: { input: 'tsf -6.5' }
}
*/
]);
};
exports.testDecrFloat = function (options) {
return helpers.audit(options, [
/*
// See notes at top of testIncr
{
setup: 'tsf -70<DOWN>',
check: { input: 'tsf 11.5' }
},
*/
{
setup: "tsf -6.5<DOWN>",
check: { input: "tsf -6.5" }
},
{
setup: "tsf -6<DOWN>",
check: { input: "tsf -6.5" }
},
{
setup: "tsf -4.5<DOWN>",
check: { input: "tsf -6" }
},
{
setup: "tsf -4<DOWN>",
check: { input: "tsf -4.5" }
},
{
setup: "tsf -3<DOWN>",
check: { input: "tsf -4.5" }
},
{
setup: "tsf -1.5<DOWN>",
check: { input: "tsf -3" }
},
{
setup: "tsf 0<DOWN>",
check: { input: "tsf -1.5" }
},
{
setup: "tsf 1.5<DOWN>",
check: { input: "tsf 0" }
},
{
setup: "tsf 2<DOWN>",
check: { input: "tsf 1.5" }
},
{
setup: "tsf 3<DOWN>",
check: { input: "tsf 1.5" }
},
{
setup: "tsf 5<DOWN>",
check: { input: "tsf 4.5" }
}
/*
// See notes at top of testIncr
{
setup: 'tsf 100<DOWN>',
check: { input: 'tsf 11.5' }
}
*/
]);
};
exports.testIncrSelection = function (options) {
/*
// Bug 829516: GCLI up/down navigation over selection is sometimes bizarre
return helpers.audit(options, [
{
setup: 'tselarr <DOWN>',
check: { hints: '2' },
exec: {}
},
{
setup: 'tselarr <DOWN><DOWN>',
check: { hints: '3' },
exec: {}
},
{
setup: 'tselarr <DOWN><DOWN><DOWN>',
check: { hints: '1' },
exec: {}
}
]);
*/
};
exports.testDecrSelection = function (options) {
/*
// Bug 829516: GCLI up/down navigation over selection is sometimes bizarre
return helpers.audit(options, [
{
setup: 'tselarr <UP>',
check: { hints: '3' }
}
]);
*/
};

View file

@ -0,0 +1,57 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard5.js");
}
// var helpers = require('./helpers');
exports.testCompleteDown = function (options) {
return helpers.audit(options, [
{
setup: "tsn e<DOWN><DOWN><DOWN><DOWN><DOWN><TAB>",
check: { input: "tsn exte " }
},
{
setup: "tsn e<DOWN><DOWN><DOWN><DOWN><TAB>",
check: { input: "tsn ext " }
},
{
setup: "tsn e<DOWN><DOWN><DOWN><TAB>",
check: { input: "tsn extend " }
},
{
setup: "tsn e<DOWN><DOWN><TAB>",
check: { input: "tsn exten " }
},
{
setup: "tsn e<DOWN><TAB>",
check: { input: "tsn exte " }
},
{
setup: "tsn e<TAB>",
check: { input: "tsn ext " }
}
]);
};

View file

@ -0,0 +1,65 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_keyboard6.js");
}
// var helpers = require('./helpers');
exports.testCompleteUp = function (options) {
return helpers.audit(options, [
{
setup: "tsn e<UP><TAB>",
check: { input: "tsn extend " }
},
{
setup: "tsn e<UP><UP><TAB>",
check: { input: "tsn exten " }
},
{
setup: "tsn e<UP><UP><UP><TAB>",
check: { input: "tsn exte " }
},
{
setup: "tsn e<UP><UP><UP><UP><TAB>",
check: { input: "tsn ext " }
},
{
setup: "tsn e<UP><UP><UP><UP><UP><TAB>",
check: { input: "tsn extend " }
},
{
setup: "tsn e<UP><UP><UP><UP><UP><UP><TAB>",
check: { input: "tsn exten " }
},
{
setup: "tsn e<UP><UP><UP><UP><UP><UP><UP><TAB>",
check: { input: "tsn exte " }
},
{
setup: "tsn e<UP><UP><UP><UP><UP><UP><UP><UP><TAB>",
check: { input: "tsn ext " }
}
]);
};

View file

@ -0,0 +1,51 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_menu.js");
}
// var helpers = require('./helpers');
exports.testOptions = function (options) {
return helpers.audit(options, [
{
setup: "tslong",
check: {
input: "tslong",
markup: "VVVVVV",
status: "ERROR",
hints: " <msg> [options]",
args: {
msg: { value: undefined, status: "INCOMPLETE" },
num: { value: undefined, status: "VALID" },
sel: { value: undefined, status: "VALID" },
bool: { value: false, status: "VALID" },
bool2: { value: false, status: "VALID" },
sel2: { value: undefined, status: "VALID" },
num2: { value: undefined, status: "VALID" }
}
}
}
]);
};

View file

@ -0,0 +1,317 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_node.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
exports.testNode = function (options) {
return helpers.audit(options, [
{
setup: "tse ",
check: {
input: "tse ",
hints: "<node> [options]",
markup: "VVVV",
cursor: 4,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: { status: "INCOMPLETE" },
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
},
{
setup: "tse :",
check: {
input: "tse :",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
arg: " :",
status: "ERROR",
message: "Syntax error in CSS query"
},
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
},
{
setup: "tse #",
check: {
input: "tse #",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " #",
status: "ERROR",
message: "Syntax error in CSS query"
},
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
},
{
setup: "tse .",
check: {
input: "tse .",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " .",
status: "ERROR",
message: "Syntax error in CSS query"
},
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
},
{
setup: "tse *",
check: {
input: "tse *",
hints: " [options]",
markup: "VVVVE",
cursor: 5,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " *",
status: "ERROR"
// message: 'Too many matches (128)'
},
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
}
]);
};
exports.testNodeDom = function (options) {
return helpers.audit(options, [
{
setup: "tse :root",
check: {
input: "tse :root",
hints: " [options]",
markup: "VVVVVVVVV",
cursor: 9,
current: "node",
status: "VALID",
args: {
command: { name: "tse" },
node: { arg: " :root", status: "VALID" },
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
},
{
setup: "tse :root ",
check: {
input: "tse :root ",
hints: "[options]",
markup: "VVVVVVVVVV",
cursor: 10,
current: "node",
status: "VALID",
args: {
command: { name: "tse" },
node: { arg: " :root ", status: "VALID" },
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
},
exec: {
},
post: function (output) {
if (!options.isRemote) {
assert.is(output.args.node.tagName, "HTML", ":root tagName");
}
}
},
{
setup: "tse #gcli-nomatch",
check: {
input: "tse #gcli-nomatch",
hints: " [options]",
markup: "VVVVIIIIIIIIIIIII",
cursor: 17,
current: "node",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: " #gcli-nomatch",
status: "INCOMPLETE",
message: "No matches"
},
nodes: { status: "VALID" },
nodes2: { status: "VALID" }
}
}
}
]);
};
exports.testNodes = function (options) {
return helpers.audit(options, [
{
setup: "tse :root --nodes *",
check: {
input: "tse :root --nodes *",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVV",
current: "nodes",
status: "VALID",
args: {
command: { name: "tse" },
node: { arg: " :root", status: "VALID" },
nodes: { arg: " --nodes *", status: "VALID" },
nodes2: { status: "VALID" }
}
},
exec: {
},
post: function (output) {
if (!options.isRemote) {
assert.is(output.args.node.tagName, "HTML", ":root tagName");
assert.ok(output.args.nodes.length > 3, "nodes length");
assert.is(output.args.nodes2.length, 0, "nodes2 length");
}
assert.is(output.data.args.node, ":root", "node data");
assert.is(output.data.args.nodes, "*", "nodes data");
assert.is(output.data.args.nodes2, "Error", "nodes2 data");
}
},
{
setup: "tse :root --nodes2 div",
check: {
input: "tse :root --nodes2 div",
hints: " [options]",
markup: "VVVVVVVVVVVVVVVVVVVVVV",
cursor: 22,
current: "nodes2",
status: "VALID",
args: {
command: { name: "tse" },
node: { arg: " :root", status: "VALID" },
nodes: { status: "VALID" },
nodes2: { arg: " --nodes2 div", status: "VALID" }
}
},
exec: {
},
post: function (output) {
if (!options.isRemote) {
assert.is(output.args.node.tagName, "HTML", ":root tagName");
assert.is(output.args.nodes.length, 0, "nodes length");
assert.is(output.args.nodes2.item(0).tagName, "DIV", "div tagName");
}
assert.is(output.data.args.node, ":root", "node data");
assert.is(output.data.args.nodes, "Error", "nodes data");
assert.is(output.data.args.nodes2, "div", "nodes2 data");
}
},
{
setup: "tse --nodes ffff",
check: {
input: "tse --nodes ffff",
hints: " <node> [options]",
markup: "VVVVIIIIIIIVIIII",
cursor: 16,
current: "nodes",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: "",
status: "INCOMPLETE"
},
nodes: {
value: undefined,
arg: " --nodes ffff",
status: "INCOMPLETE",
message: "No matches"
},
nodes2: { arg: "", status: "VALID", message: "" }
}
}
},
{
setup: "tse --nodes2 ffff",
check: {
input: "tse --nodes2 ffff",
hints: " <node> [options]",
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "nodes2",
status: "ERROR",
args: {
command: { name: "tse" },
node: {
value: undefined,
arg: "",
status: "INCOMPLETE"
},
nodes: { arg: "", status: "VALID", message: "" },
nodes2: { arg: " --nodes2 ffff", status: "VALID", message: "" }
}
}
},
]);
};

View file

@ -0,0 +1,166 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_pref1.js");
}
// var helpers = require('./helpers');
exports.testPrefShowStatus = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.requisition.system.commands.get("pref") == null,
setup: "pref s",
check: {
typed: "pref s",
hints: "et",
markup: "IIIIVI",
status: "ERROR"
}
},
{
setup: "pref show",
check: {
typed: "pref show",
hints: " <setting>",
markup: "VVVVVVVVV",
status: "ERROR"
}
},
{
setup: "pref show ",
check: {
typed: "pref show ",
hints: "eagerHelper",
markup: "VVVVVVVVVV",
status: "ERROR"
}
},
{
setup: "pref show tempTBo",
check: {
typed: "pref show tempTBo",
hints: "ol",
markup: "VVVVVVVVVVIIIIIII",
status: "ERROR"
}
},
{
setup: "pref show tempTBool",
check: {
typed: "pref show tempTBool",
markup: "VVVVVVVVVVVVVVVVVVV",
status: "VALID",
hints: ""
}
},
{
setup: "pref show tempTBool 4",
check: {
typed: "pref show tempTBool 4",
markup: "VVVVVVVVVVVVVVVVVVVVE",
status: "ERROR",
hints: ""
}
},
{
setup: "pref show tempNumber 4",
check: {
typed: "pref show tempNumber 4",
markup: "VVVVVVVVVVVVVVVVVVVVVE",
status: "ERROR",
hints: ""
}
}
]);
};
exports.testPrefSetStatus = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.requisition.system.commands.get("pref") == null,
setup: "pref s",
check: {
typed: "pref s",
hints: "et",
markup: "IIIIVI",
status: "ERROR"
}
},
{
setup: "pref set",
check: {
typed: "pref set",
hints: " <setting> <value>",
markup: "VVVVVVVV",
status: "ERROR"
}
},
{
setup: "pref xxx",
check: {
typed: "pref xxx",
markup: "IIIIVIII",
status: "ERROR"
}
},
{
setup: "pref set ",
check: {
typed: "pref set ",
hints: "eagerHelper <value>",
markup: "VVVVVVVVV",
status: "ERROR"
}
},
{
setup: "pref set tempTBo",
check: {
typed: "pref set tempTBo",
hints: "ol <value>",
markup: "VVVVVVVVVIIIIIII",
status: "ERROR"
}
},
{
skipIf: options.isRemote,
setup: "pref set tempTBool 4",
check: {
typed: "pref set tempTBool 4",
markup: "VVVVVVVVVVVVVVVVVVVE",
status: "ERROR",
hints: ""
}
},
{
setup: "pref set tempNumber 4",
check: {
typed: "pref set tempNumber 4",
markup: "VVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
hints: ""
}
}
]);
};

View file

@ -0,0 +1,119 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_pref2.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
var mockSettings = require("./mockSettings");
exports.testPrefExec = function (options) {
if (options.requisition.system.commands.get("pref") == null) {
assert.log("Skipping test; missing pref command.");
return;
}
if (options.isRemote) {
assert.log("Skipping test which assumes local settings.");
return;
}
assert.is(mockSettings.tempNumber.value, 42, "set to 42");
return helpers.audit(options, [
{
// Delegated remote types can't transfer value types so we only test for
// the value of 'value' when we're local
skipIf: options.isRemote,
setup: "pref set tempNumber 4",
check: {
setting: { value: mockSettings.tempNumber },
args: { value: { value: 4 } }
}
},
{
setup: "pref set tempNumber 4",
check: {
input: "pref set tempNumber 4",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVV",
cursor: 21,
current: "value",
status: "VALID",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "pref set" },
setting: {
arg: " tempNumber",
status: "VALID",
message: ""
},
value: {
arg: " 4",
status: "VALID",
message: ""
}
}
},
exec: {
output: ""
},
post: function () {
assert.is(mockSettings.tempNumber.value, 4, "set to 4");
}
},
{
setup: "pref reset tempNumber",
check: {
args: {
command: { name: "pref reset" },
setting: { value: mockSettings.tempNumber }
}
},
exec: {
output: ""
},
post: function () {
assert.is(mockSettings.tempNumber.value, 42, "reset to 42");
}
},
{
skipRemainingIf: function commandPrefListMissing() {
return options.requisition.system.commands.get("pref list") == null;
},
setup: "pref list tempNum",
check: {
args: {
command: { name: "pref list" },
search: { value: "tempNum" }
}
},
exec: {
output: /tempNum/
}
},
]);
};

View file

@ -0,0 +1,485 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_remotews.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
// testRemoteWs and testRemoteXhr are virtually identical.
// Changes made here should be made there too.
// They are kept separate to save adding complexity to the test system and so
// to help us select the test that are available in different environments
exports.testRemoteWebsocket = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.isRemote || options.isNode || options.isFirefox,
setup: "remote ",
check: {
input: "remote ",
hints: "",
markup: "EEEEEEV",
cursor: 7,
current: "__command",
status: "ERROR",
options: [ ],
message: "Can't use 'remote'.",
predictions: [ ],
unassigned: [ ],
}
},
{
setup: "connect remote",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
error: false
}
},
{
setup: "disconnect remote",
check: {
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
}
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "connect remote --method websocket",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
error: false
}
},
{
setup: "disconnect remote",
check: {
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
}
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "connect remote --method websocket",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
output: /^Added [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "remote ",
check: {
input: "remote ",
// PhantomJS fails on this. Unsure why
// hints: ' {',
markup: "IIIIIIV",
status: "ERROR",
optionsIncludes: [
"remote", "remote cd", "remote context", "remote echo",
"remote exec", "remote exit", "remote firefox", "remote help",
"remote intro", "remote make"
],
message: "",
predictionsIncludes: [ "remote" ],
unassigned: [ ],
}
},
{
setup: "remote echo hello world",
check: {
input: "remote echo hello world",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVV",
cursor: 23,
current: "message",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote echo" },
message: {
value: "hello world",
arg: " hello world",
status: "VALID",
message: ""
}
}
},
exec: {
output: "hello world",
type: "string",
error: false
}
},
{
setup: "remote exec ls",
check: {
input: "remote exec ls",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: {
value: "ls",
arg: " ls",
status: "VALID",
message: ""
}
}
},
exec: {
// output: '', We can't rely on the contents of the FS
type: "output",
error: false
}
},
{
setup: "remote sleep mistake",
check: {
input: "remote sleep mistake",
hints: "",
markup: "VVVVVVVVVVVVVEEEEEEE",
cursor: 20,
current: "length",
status: "ERROR",
options: [ ],
message: 'Can\'t convert "mistake" to a number.',
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote sleep" },
length: {
value: undefined,
arg: " mistake",
status: "ERROR",
message: 'Can\'t convert "mistake" to a number.'
}
}
}
},
{
setup: "remote sleep 1",
check: {
input: "remote sleep 1",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "length",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote sleep" },
length: { value: 1, arg: " 1", status: "VALID", message: "" }
}
},
exec: {
output: "Done",
type: "string",
error: false
}
},
{
setup: "remote help ",
skipIf: true, // The help command is not remotable
check: {
input: "remote help ",
hints: "[search]",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "search",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote help" },
search: {
value: undefined,
arg: "",
status: "VALID",
message: ""
}
}
},
exec: {
output: "",
type: "string",
error: false
}
},
{
setup: "remote intro",
check: {
input: "remote intro",
hints: "",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "__command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote intro" }
}
},
exec: {
output: [
/GCLI is an experiment/,
/F1\/Escape/
],
type: "intro",
error: false
}
},
{
setup: "context remote",
check: {
input: "context remote",
// hints: ' {',
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "prefix",
status: "VALID",
optionsContains: [
"remote", "remote cd", "remote echo", "remote exec", "remote exit",
"remote firefox", "remote help", "remote intro", "remote make"
],
message: "",
// predictionsContains: [
// 'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit',
// 'remote firefox', 'remote help', 'remote intro', 'remote make',
// 'remote pref'
// ],
unassigned: [ ],
args: {
command: { name: "context" },
prefix: {
arg: " remote",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Using remote as a command prefix",
type: "string",
error: false
}
},
{
setup: "exec ls",
check: {
input: "exec ls",
hints: "",
markup: "VVVVVVV",
cursor: 7,
current: "command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { value: "ls", arg: " ls", status: "VALID", message: "" },
}
},
exec: {
// output: '', We can't rely on the contents of the filesystem
type: "output",
error: false
}
},
{
setup: "echo hello world",
check: {
input: "echo hello world",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
cursor: 16,
current: "message",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote echo" },
message: {
value: "hello world",
arg: " hello world",
status: "VALID",
message: ""
}
}
},
exec: {
output: /^hello world$/,
type: "string",
error: false
}
},
{
setup: "context",
check: {
input: "context",
hints: " [prefix]",
markup: "VVVVVVV",
cursor: 7,
current: "__command",
status: "VALID",
optionsContains: [
"remote", "remote cd", "remote echo", "remote exec", "remote exit",
"remote firefox", "remote help", "remote intro", "remote make"
],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "context" },
prefix: { value: undefined, arg: "", status: "VALID", message: "" }
}
},
exec: {
output: "Command prefix is unset",
type: "string",
error: false
}
},
{
setup: "disconnect ",
check: {
input: "disconnect ",
hints: "remote",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "prefix",
status: "ERROR",
options: [ "remote" ],
message: "",
predictions: [ "remote" ],
unassigned: [ ],
args: {
command: { name: "disconnect" },
prefix: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for 'prefix'."
}
}
}
},
{
setup: "disconnect remote",
check: {
input: "disconnect remote",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
unassigned: [ ],
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
},
arg: " remote",
status: "VALID",
message: ""
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "remote ",
check: {
input: "remote ",
hints: "",
markup: "EEEEEEV",
cursor: 7,
current: "__command",
status: "ERROR",
options: [ ],
message: "Can't use 'remote'.",
predictions: [ ],
unassigned: [ ],
}
}
]);
};

View file

@ -0,0 +1,485 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_remotexhr.js");
}
// var assert = require('../testharness/assert');
// var helpers = require('./helpers');
// testRemoteWs and testRemoteXhr are virtually identical.
// Changes made here should be made there too.
// They are kept separate to save adding complexity to the test system and so
// to help us select the test that are available in different environments
exports.testRemoteXhr = function (options) {
return helpers.audit(options, [
{
skipRemainingIf: options.isRemote || options.isNode || options.isFirefox,
setup: "remote ",
check: {
input: "remote ",
hints: "",
markup: "EEEEEEV",
cursor: 7,
current: "__command",
status: "ERROR",
options: [ ],
message: "Can't use 'remote'.",
predictions: [ ],
unassigned: [ ],
}
},
{
setup: "connect remote",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
error: false
}
},
{
setup: "disconnect remote",
check: {
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
}
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "connect remote --method xhr",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
error: false
}
},
{
setup: "disconnect remote",
check: {
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
}
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "connect remote --method xhr",
check: {
args: {
prefix: { value: "remote" },
url: { value: undefined }
}
},
exec: {
output: /^Added [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "remote ",
check: {
input: "remote ",
// PhantomJS fails on this. Unsure why
// hints: ' {',
markup: "IIIIIIV",
status: "ERROR",
optionsIncludes: [
"remote", "remote cd", "remote context", "remote echo",
"remote exec", "remote exit", "remote firefox", "remote help",
"remote intro", "remote make"
],
message: "",
predictionsIncludes: [ "remote" ],
unassigned: [ ],
}
},
{
setup: "remote echo hello world",
check: {
input: "remote echo hello world",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVV",
cursor: 23,
current: "message",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote echo" },
message: {
value: "hello world",
arg: " hello world",
status: "VALID",
message: ""
}
}
},
exec: {
output: "hello world",
type: "string",
error: false
}
},
{
setup: "remote exec ls",
check: {
input: "remote exec ls",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: {
value: "ls",
arg: " ls",
status: "VALID",
message: ""
}
}
},
exec: {
// output: '', We can't rely on the contents of the FS
type: "output",
error: false
}
},
{
setup: "remote sleep mistake",
check: {
input: "remote sleep mistake",
hints: "",
markup: "VVVVVVVVVVVVVEEEEEEE",
cursor: 20,
current: "length",
status: "ERROR",
options: [ ],
message: 'Can\'t convert "mistake" to a number.',
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote sleep" },
length: {
value: undefined,
arg: " mistake",
status: "ERROR",
message: 'Can\'t convert "mistake" to a number.'
}
}
}
},
{
setup: "remote sleep 1",
check: {
input: "remote sleep 1",
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "length",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote sleep" },
length: { value: 1, arg: " 1", status: "VALID", message: "" }
}
},
exec: {
output: "Done",
type: "string",
error: false
}
},
{
setup: "remote help ",
skipIf: true, // The help command is not remotable
check: {
input: "remote help ",
hints: "[search]",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "search",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote help" },
search: {
value: undefined,
arg: "",
status: "VALID",
message: ""
}
}
},
exec: {
output: "",
type: "string",
error: false
}
},
{
setup: "remote intro",
check: {
input: "remote intro",
hints: "",
markup: "VVVVVVVVVVVV",
cursor: 12,
current: "__command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote intro" }
}
},
exec: {
output: [
/GCLI is an experiment/,
/F1\/Escape/
],
type: "intro",
error: false
}
},
{
setup: "context remote",
check: {
input: "context remote",
// hints: ' {',
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "prefix",
status: "VALID",
optionsContains: [
"remote", "remote cd", "remote echo", "remote exec", "remote exit",
"remote firefox", "remote help", "remote intro", "remote make"
],
message: "",
// predictionsContains: [
// 'remote', 'remote cd', 'remote echo', 'remote exec', 'remote exit',
// 'remote firefox', 'remote help', 'remote intro', 'remote make',
// 'remote pref'
// ],
unassigned: [ ],
args: {
command: { name: "context" },
prefix: {
arg: " remote",
status: "VALID",
message: ""
}
}
},
exec: {
output: "Using remote as a command prefix",
type: "string",
error: false
}
},
{
setup: "exec ls",
check: {
input: "exec ls",
hints: "",
markup: "VVVVVVV",
cursor: 7,
current: "command",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { value: "ls", arg: " ls", status: "VALID", message: "" },
}
},
exec: {
// output: '', We can't rely on the contents of the filesystem
type: "output",
error: false
}
},
{
setup: "echo hello world",
check: {
input: "echo hello world",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
cursor: 16,
current: "message",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "remote echo" },
message: {
value: "hello world",
arg: " hello world",
status: "VALID",
message: ""
}
}
},
exec: {
output: /^hello world$/,
type: "string",
error: false
}
},
{
setup: "context",
check: {
input: "context",
hints: " [prefix]",
markup: "VVVVVVV",
cursor: 7,
current: "__command",
status: "VALID",
optionsContains: [
"remote", "remote cd", "remote echo", "remote exec", "remote exit",
"remote firefox", "remote help", "remote intro", "remote make"
],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "context" },
prefix: { value: undefined, arg: "", status: "VALID", message: "" }
}
},
exec: {
output: "Command prefix is unset",
type: "string",
error: false
}
},
{
setup: "disconnect ",
check: {
input: "disconnect ",
hints: "remote",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "prefix",
status: "ERROR",
options: [ "remote" ],
message: "",
predictions: [ "remote" ],
unassigned: [ ],
args: {
command: { name: "disconnect" },
prefix: {
value: undefined,
arg: "",
status: "INCOMPLETE",
message: "Value required for 'prefix'."
}
}
}
},
{
setup: "disconnect remote",
check: {
input: "disconnect remote",
hints: "",
markup: "VVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
unassigned: [ ],
args: {
prefix: {
value: function (front) {
assert.is(front.prefix, "remote", "disconnecting remote");
},
arg: " remote",
status: "VALID",
message: ""
}
}
},
exec: {
output: /^Removed [0-9]* commands.$/,
type: "string",
error: false
}
},
{
setup: "remote ",
check: {
input: "remote ",
hints: "",
markup: "EEEEEEV",
cursor: 7,
current: "__command",
status: "ERROR",
options: [ ],
message: "Can't use 'remote'.",
predictions: [ ],
unassigned: [ ],
}
}
]);
};

View file

@ -0,0 +1,154 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_resource.js");
}
// var helpers = require('./helpers');
// var assert = require('../testharness/assert');
var util = require("gcli/util/util");
var resource = require("gcli/types/resource");
var Status = require("gcli/types/types").Status;
exports.testCommand = function (options) {
return helpers.audit(options, [
{
setup: "tsres ",
check: {
predictionsContains: [ "inline-css" ],
}
}
]);
};
exports.testAllPredictions1 = function (options) {
if (options.isRemote) {
assert.log("Can't directly test remote types locally.");
return;
}
var context = options.requisition.conversionContext;
var resource = options.requisition.system.types.createType("resource");
return resource.getLookup(context).then(function (opts) {
assert.ok(opts.length > 1, "have all resources");
return util.promiseEach(opts, function (prediction) {
return checkPrediction(resource, prediction, context);
});
});
};
exports.testScriptPredictions = function (options) {
if (options.isRemote || options.isNode) {
assert.log("Can't directly test remote types locally.");
return;
}
var context = options.requisition.conversionContext;
var types = options.requisition.system.types;
var resource = types.createType({ name: "resource", include: "text/javascript" });
return resource.getLookup(context).then(function (opts) {
assert.ok(opts.length > 1, "have js resources");
return util.promiseEach(opts, function (prediction) {
return checkPrediction(resource, prediction, context);
});
});
};
exports.testStylePredictions = function (options) {
if (options.isRemote) {
assert.log("Can't directly test remote types locally.");
return;
}
var context = options.requisition.conversionContext;
var types = options.requisition.system.types;
var resource = types.createType({ name: "resource", include: "text/css" });
return resource.getLookup(context).then(function (opts) {
assert.ok(opts.length >= 1, "have css resources");
return util.promiseEach(opts, function (prediction) {
return checkPrediction(resource, prediction, context);
});
});
};
exports.testAllPredictions2 = function (options) {
if (options.isRemote) {
assert.log("Can't directly test remote types locally.");
return;
}
var context = options.requisition.conversionContext;
var types = options.requisition.system.types;
var scriptRes = types.createType({ name: "resource", include: "text/javascript" });
return scriptRes.getLookup(context).then(function (scriptOptions) {
var styleRes = types.createType({ name: "resource", include: "text/css" });
return styleRes.getLookup(context).then(function (styleOptions) {
var allRes = types.createType({ name: "resource" });
return allRes.getLookup(context).then(function (allOptions) {
assert.is(scriptOptions.length + styleOptions.length,
allOptions.length,
"split");
});
});
});
};
exports.testAllPredictions3 = function (options) {
if (options.isRemote) {
assert.log("Can't directly test remote types locally.");
return;
}
var context = options.requisition.conversionContext;
var types = options.requisition.system.types;
var res1 = types.createType({ name: "resource" });
return res1.getLookup(context).then(function (options1) {
var res2 = types.createType("resource");
return res2.getLookup(context).then(function (options2) {
assert.is(options1.length, options2.length, "type spec");
});
});
};
function checkPrediction(res, prediction, context) {
var name = prediction.name;
var value = prediction.value;
return res.parseString(name, context).then(function (conversion) {
assert.is(conversion.getStatus(), Status.VALID, "status VALID for " + name);
assert.is(conversion.value, value, "value for " + name);
assert.is(typeof value.loadContents, "function", "resource for " + name);
assert.is(typeof value.element, "object", "resource for " + name);
return Promise.resolve(res.stringify(value, context)).then(function (strung) {
assert.is(strung, name, "stringify for " + name);
});
});
}

View file

@ -0,0 +1,248 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_short.js");
}
// var helpers = require('./helpers');
exports.testBasic = function (options) {
return helpers.audit(options, [
{
setup: "tshidden -v",
check: {
input: "tshidden -v",
hints: " <string>",
markup: "VVVVVVVVVII",
cursor: 11,
current: "visible",
status: "ERROR",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tshidden" },
visible: {
value: undefined,
arg: " -v",
status: "INCOMPLETE"
},
invisiblestring: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisibleboolean: {
value: false,
arg: "",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tshidden -v v",
check: {
input: "tshidden -v v",
hints: "",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "visible",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tshidden" },
visible: {
value: "v",
arg: " -v v",
status: "VALID",
message: ""
},
invisiblestring: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisibleboolean: {
value: false,
arg: "",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tshidden -i i",
check: {
input: "tshidden -i i",
hints: " [options]",
markup: "VVVVVVVVVVVVV",
cursor: 13,
current: "invisiblestring",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tshidden" },
visible: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisiblestring: {
value: "i",
arg: " -i i",
status: "VALID",
message: ""
},
invisibleboolean: {
value: false,
arg: "",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tshidden -b",
check: {
input: "tshidden -b",
hints: " [options]",
markup: "VVVVVVVVVVV",
cursor: 11,
current: "invisibleboolean",
status: "VALID",
options: [ ],
message: "",
predictions: [ ],
unassigned: [ ],
args: {
command: { name: "tshidden" },
visible: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisiblestring: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisibleboolean: {
value: true,
arg: " -b",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tshidden -j",
check: {
input: "tshidden -j",
hints: " [options]",
markup: "VVVVVVVVVEE",
cursor: 11,
current: "__unassigned",
status: "ERROR",
options: [ ],
message: "Can't use '-j'.",
predictions: [ ],
unassigned: [ " -j" ],
args: {
command: { name: "tshidden" },
visible: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisiblestring: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisibleboolean: {
value: false,
arg: "",
status: "VALID",
message: ""
}
}
}
},
{
setup: "tshidden -v jj -b --",
check: {
input: "tshidden -v jj -b --",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVEE",
cursor: 20,
current: "__unassigned",
status: "ERROR",
options: [ ],
message: "Can't use '--'.",
predictions: [ ],
unassigned: [ " --" ],
args: {
command: { name: "tshidden" },
visible: {
value: "jj",
arg: " -v jj",
status: "VALID",
message: ""
},
invisiblestring: {
value: undefined,
arg: "",
status: "VALID",
message: ""
},
invisibleboolean: {
value: true,
arg: " -b",
status: "VALID",
message: ""
}
}
}
}
]);
};

View file

@ -0,0 +1,72 @@
/*
* Copyright (c) 2009 Panagiotis Astithas
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_spell.js");
}
// var assert = require('../testharness/assert');
var spell = require("gcli/util/spell");
exports.testSpellerSimple = function (options) {
var alternatives = [
"window", "document", "InstallTrigger", "requirejs", "require", "define",
"console", "location", "constructor", "getInterface", "external", "sidebar"
];
assert.is(spell.correct("document", alternatives), "document");
assert.is(spell.correct("documen", alternatives), "document");
assert.is(spell.correct("ocument", alternatives), "document");
assert.is(spell.correct("odcument", alternatives), "document");
assert.is(spell.correct("=========", alternatives), undefined);
};
exports.testRank = function (options) {
var distances = spell.rank("fred", [ "banana", "fred", "ed", "red", "FRED" ]);
assert.is(distances.length, 5, "rank length");
assert.is(distances[0].name, "fred", "fred name #0");
assert.is(distances[1].name, "FRED", "FRED name #1");
assert.is(distances[2].name, "red", "red name #2");
assert.is(distances[3].name, "ed", "ed name #3");
assert.is(distances[4].name, "banana", "banana name #4");
assert.is(distances[0].dist, 0, "fred dist 0");
assert.is(distances[1].dist, 4, "FRED dist 4");
assert.is(distances[2].dist, 10, "red dist 10");
assert.is(distances[3].dist, 20, "ed dist 20");
assert.is(distances[4].dist, 100, "banana dist 100");
};
exports.testRank2 = function (options) {
var distances = spell.rank("caps", [ "CAPS", "false" ]);
assert.is(JSON.stringify(distances),
'[{"name":"CAPS","dist":4},{"name":"false","dist":50}]',
'spell.rank("caps", [ "CAPS", "false" ]');
};
exports.testDistancePrefix = function (options) {
assert.is(spell.distancePrefix("fred", "freddy"), 0, "distancePrefix fred");
assert.is(spell.distancePrefix("FRED", "freddy"), 4, "distancePrefix FRED");
};

View file

@ -0,0 +1,67 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_split.js");
}
// var assert = require('../testharness/assert');
var cli = require("gcli/cli");
exports.testSplitSimple = function (options) {
var args = cli.tokenize("s");
options.requisition._split(args);
assert.is(args.length, 0);
assert.is(options.requisition.commandAssignment.arg.text, "s");
};
exports.testFlatCommand = function (options) {
var args = cli.tokenize("tsv");
options.requisition._split(args);
assert.is(args.length, 0);
assert.is(options.requisition.commandAssignment.value.name, "tsv");
args = cli.tokenize("tsv a b");
options.requisition._split(args);
assert.is(options.requisition.commandAssignment.value.name, "tsv");
assert.is(args.length, 2);
assert.is(args[0].text, "a");
assert.is(args[1].text, "b");
};
exports.testJavascript = function (options) {
if (!options.requisition.system.commands.get("{")) {
assert.log("Skipping testJavascript because { is not registered");
return;
}
var args = cli.tokenize("{");
options.requisition._split(args);
assert.is(args.length, 1);
assert.is(args[0].text, "");
assert.is(options.requisition.commandAssignment.arg.text, "");
assert.is(options.requisition.commandAssignment.value.name, "{");
};
// BUG 663081 - add tests for sub commands

View file

@ -0,0 +1,270 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_string.js");
}
// var helpers = require('./helpers');
exports.testNewLine = function (options) {
return helpers.audit(options, [
{
setup: "echo a\\nb",
check: {
input: "echo a\\nb",
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "message",
status: "VALID",
args: {
command: { name: "echo" },
message: {
value: "a\nb",
arg: " a\\nb",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testTab = function (options) {
return helpers.audit(options, [
{
setup: "echo a\\tb",
check: {
input: "echo a\\tb",
hints: "",
markup: "VVVVVVVVV",
cursor: 9,
current: "message",
status: "VALID",
args: {
command: { name: "echo" },
message: {
value: "a\tb",
arg: " a\\tb",
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testEscape = function (options) {
return helpers.audit(options, [
{
// What's typed is actually:
// tsrsrsr a\\ b c
setup: "tsrsrsr a\\\\ b c",
check: {
input: "tsrsrsr a\\\\ b c",
hints: "",
markup: "VVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: { value: "a\\", arg: " a\\\\", status: "VALID", message: "" },
p2: { value: "b", arg: " b", status: "VALID", message: "" },
p3: { value: "c", arg: " c", status: "VALID", message: "" },
}
}
},
{
// What's typed is actually:
// tsrsrsr abc\\ndef asd asd
setup: "tsrsrsr abc\\\\ndef asd asd",
check: {
input: "tsrsrsr abc\\\\ndef asd asd",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: {
value: "abc\\ndef",
arg: " abc\\\\ndef",
status: "VALID",
message: ""
},
p2: { value: "asd", arg: " asd", status: "VALID", message: "" },
p3: { value: "asd", arg: " asd", status: "VALID", message: "" },
}
}
}
]);
};
exports.testBlank = function (options) {
return helpers.audit(options, [
{
setup: 'tsrsrsr a "" c',
check: {
input: 'tsrsrsr a "" c',
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "p3",
status: "ERROR",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: {
value: "a",
arg: " a",
status: "VALID",
message: ""
},
p2: {
value: undefined,
arg: ' ""',
status: "INCOMPLETE"
},
p3: {
value: "c",
arg: " c",
status: "VALID",
message: ""
}
}
}
},
{
setup: 'tsrsrsr a b ""',
check: {
input: 'tsrsrsr a b ""',
hints: "",
markup: "VVVVVVVVVVVVVV",
cursor: 14,
current: "p3",
status: "VALID",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: {
value: "a",
arg: " a",
status:"VALID",
message: "" },
p2: {
value: "b",
arg: " b",
status: "VALID",
message: ""
},
p3: {
value: "",
arg: ' ""',
status: "VALID",
message: ""
}
}
}
}
]);
};
exports.testBlankWithParam = function (options) {
return helpers.audit(options, [
{
setup: "tsrsrsr a --p3",
check: {
input: "tsrsrsr a --p3",
hints: " <string> <p2>",
markup: "VVVVVVVVVVVVVVV",
cursor: 15,
current: "p3",
status: "ERROR",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: { value: "a", arg: " a", status: "VALID", message: "" },
p2: { value: undefined, arg: "", status: "INCOMPLETE" },
p3: { value: "", arg: " --p3", status: "VALID", message: "" },
}
}
},
{
setup: "tsrsrsr a --p3 ",
check: {
input: "tsrsrsr a --p3 ",
hints: "<string> <p2>",
markup: "VVVVVVVVVVVVVVVV",
cursor: 16,
current: "p3",
status: "ERROR",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: { value: "a", arg: " a", status: "VALID", message: "" },
p2: { value: undefined, arg: "", status: "INCOMPLETE" },
p3: { value: "", arg: " --p3 ", status: "VALID", message: "" },
}
}
},
{
setup: 'tsrsrsr a --p3 "',
check: {
input: 'tsrsrsr a --p3 "',
hints: " <p2>",
markup: "VVVVVVVVVVVVVVVVV",
cursor: 17,
current: "p3",
status: "ERROR",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: { value: "a", arg: " a", status: "VALID", message: "" },
p2: { value: undefined, arg: "", status: "INCOMPLETE" },
p3: { value: "", arg: ' --p3 "', status: "VALID", message: "" },
}
}
},
{
setup: 'tsrsrsr a --p3 ""',
check: {
input: 'tsrsrsr a --p3 ""',
hints: " <p2>",
markup: "VVVVVVVVVVVVVVVVVV",
cursor: 18,
current: "p3",
status: "ERROR",
message: "",
args: {
command: { name: "tsrsrsr" },
p1: { value: "a", arg: " a", status: "VALID", message: "" },
p2: { value: undefined, arg: "", status: "INCOMPLETE" },
p3: { value: "", arg: ' --p3 ""', status: "VALID", message: "" },
}
}
}
]);
};

View file

@ -0,0 +1,290 @@
/*
* Copyright 2012, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
const exports = {};
function test() {
helpers.runTestModule(exports, "browser_gcli_tokenize.js");
}
// var assert = require('../testharness/assert');
var cli = require("gcli/cli");
exports.testBlanks = function (options) {
var args;
args = cli.tokenize("");
assert.is(args.length, 1);
assert.is(args[0].text, "");
assert.is(args[0].prefix, "");
assert.is(args[0].suffix, "");
args = cli.tokenize(" ");
assert.is(args.length, 1);
assert.is(args[0].text, "");
assert.is(args[0].prefix, " ");
assert.is(args[0].suffix, "");
};
exports.testTokSimple = function (options) {
var args;
args = cli.tokenize("s");
assert.is(args.length, 1);
assert.is(args[0].text, "s");
assert.is(args[0].prefix, "");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "Argument");
args = cli.tokenize("s s");
assert.is(args.length, 2);
assert.is(args[0].text, "s");
assert.is(args[0].prefix, "");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "Argument");
assert.is(args[1].text, "s");
assert.is(args[1].prefix, " ");
assert.is(args[1].suffix, "");
assert.is(args[1].type, "Argument");
};
exports.testJavascript = function (options) {
var args;
args = cli.tokenize("{x}");
assert.is(args.length, 1);
assert.is(args[0].text, "x");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{ x }");
assert.is(args.length, 1);
assert.is(args[0].text, "x");
assert.is(args[0].prefix, "{ ");
assert.is(args[0].suffix, " }");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{x} {y}");
assert.is(args.length, 2);
assert.is(args[0].text, "x");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
assert.is(args[1].text, "y");
assert.is(args[1].prefix, " {");
assert.is(args[1].suffix, "}");
assert.is(args[1].type, "ScriptArgument");
args = cli.tokenize("{x}{y}");
assert.is(args.length, 2);
assert.is(args[0].text, "x");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
assert.is(args[1].text, "y");
assert.is(args[1].prefix, "{");
assert.is(args[1].suffix, "}");
assert.is(args[1].type, "ScriptArgument");
args = cli.tokenize("{");
assert.is(args.length, 1);
assert.is(args[0].text, "");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{ ");
assert.is(args.length, 1);
assert.is(args[0].text, "");
assert.is(args[0].prefix, "{ ");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{x");
assert.is(args.length, 1);
assert.is(args[0].text, "x");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "ScriptArgument");
};
exports.testRegularNesting = function (options) {
var args;
args = cli.tokenize('{"x"}');
assert.is(args.length, 1);
assert.is(args[0].text, '"x"');
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{'x'}");
assert.is(args.length, 1);
assert.is(args[0].text, "'x'");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize('"{x}"');
assert.is(args.length, 1);
assert.is(args[0].text, "{x}");
assert.is(args[0].prefix, '"');
assert.is(args[0].suffix, '"');
assert.is(args[0].type, "Argument");
args = cli.tokenize("'{x}'");
assert.is(args.length, 1);
assert.is(args[0].text, "{x}");
assert.is(args[0].prefix, "'");
assert.is(args[0].suffix, "'");
assert.is(args[0].type, "Argument");
};
exports.testDeepNesting = function (options) {
var args;
args = cli.tokenize("{{}}");
assert.is(args.length, 1);
assert.is(args[0].text, "{}");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{{x} {y}}");
assert.is(args.length, 1);
assert.is(args[0].text, "{x} {y}");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
args = cli.tokenize("{{w} {{{x}}}} {y} {{{z}}}");
assert.is(args.length, 3);
assert.is(args[0].text, "{w} {{{x}}}");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
assert.is(args[1].text, "y");
assert.is(args[1].prefix, " {");
assert.is(args[1].suffix, "}");
assert.is(args[1].type, "ScriptArgument");
assert.is(args[2].text, "{{z}}");
assert.is(args[2].prefix, " {");
assert.is(args[2].suffix, "}");
assert.is(args[2].type, "ScriptArgument");
args = cli.tokenize("{{w} {{{x}}} {y} {{{z}}}");
assert.is(args.length, 1);
assert.is(args[0].text, "{w} {{{x}}} {y} {{{z}}}");
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "ScriptArgument");
};
exports.testStrangeNesting = function (options) {
var args;
// Note: When we get real JS parsing this should break
args = cli.tokenize('{"x}"}');
assert.is(args.length, 2);
assert.is(args[0].text, '"x');
assert.is(args[0].prefix, "{");
assert.is(args[0].suffix, "}");
assert.is(args[0].type, "ScriptArgument");
assert.is(args[1].text, "}");
assert.is(args[1].prefix, '"');
assert.is(args[1].suffix, "");
assert.is(args[1].type, "Argument");
};
exports.testComplex = function (options) {
var args;
args = cli.tokenize(" 1234 '12 34'");
assert.is(args.length, 2);
assert.is(args[0].text, "1234");
assert.is(args[0].prefix, " ");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "Argument");
assert.is(args[1].text, "12 34");
assert.is(args[1].prefix, " '");
assert.is(args[1].suffix, "'");
assert.is(args[1].type, "Argument");
args = cli.tokenize('12\'34 "12 34" \\'); // 12'34 "12 34" \
assert.is(args.length, 3);
assert.is(args[0].text, "12'34");
assert.is(args[0].prefix, "");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "Argument");
assert.is(args[1].text, "12 34");
assert.is(args[1].prefix, ' "');
assert.is(args[1].suffix, '"');
assert.is(args[1].type, "Argument");
assert.is(args[2].text, "\\");
assert.is(args[2].prefix, " ");
assert.is(args[2].suffix, "");
assert.is(args[2].type, "Argument");
};
exports.testPathological = function (options) {
var args;
args = cli.tokenize('a\\ b \\t\\n\\r \\\'x\\\" \'d'); // a_b \t\n\r \'x\" 'd
assert.is(args.length, 4);
assert.is(args[0].text, "a\\ b");
assert.is(args[0].prefix, "");
assert.is(args[0].suffix, "");
assert.is(args[0].type, "Argument");
assert.is(args[1].text, "\\t\\n\\r");
assert.is(args[1].prefix, " ");
assert.is(args[1].suffix, "");
assert.is(args[1].type, "Argument");
assert.is(args[2].text, '\\\'x\\"');
assert.is(args[2].prefix, " ");
assert.is(args[2].suffix, "");
assert.is(args[2].type, "Argument");
assert.is(args[3].text, "d");
assert.is(args[3].prefix, " '");
assert.is(args[3].suffix, "");
assert.is(args[3].type, "Argument");
};

Some files were not shown because too many files have changed in this diff Show more