зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1408921 - Split browser_webconsole_autocomplete_keys.js in the new console frontend; r=bgrins.
The test was very long and tested different bugs. Splitting it make all the test case clearer. MozReview-Commit-ID: 4z45RE3eJoC --HG-- rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_autocomplete_keys.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js extra : rebase_source : c9c12ee909d843bf5f3b9c1312057c5552e23df8
This commit is contained in:
Родитель
c91c991524
Коммит
020b588ced
|
@ -196,7 +196,13 @@ skip-if = true # Bug 1403188
|
|||
# old console skip-if = e10s # Bug 1042253 - webconsole e10s tests
|
||||
[browser_jsterm_accessibility.js]
|
||||
[browser_jsterm_add_edited_input_to_history.js]
|
||||
[browser_jsterm_autocomplete_array_no_index.js]
|
||||
[browser_jsterm_autocomplete_escape_key.js]
|
||||
[browser_jsterm_autocomplete_helpers.js]
|
||||
[browser_jsterm_autocomplete_inside_text.js]
|
||||
[browser_jsterm_autocomplete_nav_and_tab_key.js]
|
||||
[browser_jsterm_autocomplete_return_key_no_selection.js]
|
||||
[browser_jsterm_autocomplete_return_key.js]
|
||||
[browser_jsterm_autocomplete-properties-with-non-alphanumeric-names.js]
|
||||
[browser_jsterm_copy_command.js]
|
||||
[browser_jsterm_dollar.js]
|
||||
|
@ -218,8 +224,6 @@ skip-if = true # Bug 1404850
|
|||
skip-if = true # Bug 1408919
|
||||
[browser_webconsole_autocomplete_in_debugger_stackframe.js]
|
||||
skip-if = true # Bug 1408920
|
||||
[browser_webconsole_autocomplete_keys.js]
|
||||
skip-if = true # Bug 1408921
|
||||
[browser_webconsole_autocomplete_popup.js]
|
||||
skip-if = true # Bug 1408922
|
||||
[browser_webconsole_autocomplete_popup_close_on_tab_switch.js]
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 585991.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
window.foo = [1,2,3];
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 585991 - Autocomplete popup on array</body>`;
|
||||
|
||||
add_task(async function () {
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
let onPopUpOpen = popup.once("popup-opened");
|
||||
|
||||
info("wait for popup to show");
|
||||
jsterm.setInputValue("foo");
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
|
||||
await onPopUpOpen;
|
||||
|
||||
let popupItems = popup.getItems().map(e => e.label);
|
||||
is(popupItems.includes("0"), false, "Completing on an array doesn't show numbers.");
|
||||
|
||||
info("press Escape to close the popup");
|
||||
const onPopupClose = popup.once("popup-closed");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
|
||||
await onPopupClose;
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 585991.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
/* Create a prototype-less object so popup does not contain native
|
||||
* Object prototype properties.
|
||||
*/
|
||||
window.foo = Object.create(null);
|
||||
Object.assign(window.foo, {
|
||||
item0: "value0",
|
||||
item1: "value1",
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 585991 - autocomplete popup escape key usage test</body>`;
|
||||
|
||||
add_task(async function () {
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
info("web console opened");
|
||||
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
let onPopUpOpen = popup.once("popup-opened");
|
||||
|
||||
info("wait for completion: window.foo.");
|
||||
jsterm.setInputValue("window.foo");
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
|
||||
await onPopUpOpen;
|
||||
|
||||
ok(popup.isOpen, "popup is open");
|
||||
ok(popup.itemCount, "popup has items");
|
||||
|
||||
info("press Escape to close the popup");
|
||||
const onPopupClose = popup.once("popup-closed");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
|
||||
await onPopupClose;
|
||||
|
||||
ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
|
||||
is(jsterm.getInputValue(), "window.foo.", "completion was cancelled");
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
});
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 812618.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
window.testBugA = "hello world";
|
||||
window.testBugB = "hello world 2";
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 812618 - test completion inside text</body>`;
|
||||
|
||||
add_task(async function () {
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
info("web console opened");
|
||||
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
const onPopUpOpen = popup.once("popup-opened");
|
||||
|
||||
const dumpString = "dump(window.testBu)";
|
||||
jsterm.setInputValue(dumpString);
|
||||
inputNode.selectionStart = inputNode.selectionEnd = dumpString.indexOf(")");
|
||||
EventUtils.synthesizeKey("g", {});
|
||||
|
||||
await onPopUpOpen;
|
||||
|
||||
ok(popup.isOpen, "popup is open");
|
||||
is(popup.itemCount, 2, "popup.itemCount is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
|
||||
ok(!completeNode.value, "completeNode.value is empty");
|
||||
|
||||
let items = popup.getItems().map(e => e.label);
|
||||
let expectedItems = ["testBugB", "testBugA"];
|
||||
is(items.join("-"), expectedItems.join("-"), "getItems returns the items we expect");
|
||||
|
||||
info("press Tab and wait for popup to hide");
|
||||
const onPopupClose = popup.once("popup-closed");
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
|
||||
await onPopupClose;
|
||||
|
||||
// At this point the completion suggestion should be accepted.
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
const expectedInput = "dump(window.testBugB)";
|
||||
is(jsterm.getInputValue(), expectedInput, "completion was successful after VK_TAB");
|
||||
is(inputNode.selectionStart, expectedInput.length - 1, "cursor location is correct");
|
||||
is(inputNode.selectionStart, inputNode.selectionEnd, "cursor location (confirmed)");
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
});
|
|
@ -0,0 +1,115 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 585991.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
/* Create a prototype-less object so popup does not contain native
|
||||
* Object prototype properties.
|
||||
*/
|
||||
window.foo = Object.create(null);
|
||||
Object.assign(window.foo, {
|
||||
item0: "value0",
|
||||
item1: "value1",
|
||||
item2: "value2",
|
||||
item3: "value3",
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 585991 - autocomplete popup navigation and tab key usage test</body>`;
|
||||
|
||||
add_task(async function () {
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
info("web console opened");
|
||||
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
|
||||
const onPopUpOpen = popup.once("popup-opened");
|
||||
jsterm.setInputValue("window.foo");
|
||||
|
||||
// Shows the popup
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
await onPopUpOpen;
|
||||
|
||||
ok(popup.isOpen, "popup is open");
|
||||
|
||||
const popupItems = popup.getItems().map(e => e.label);
|
||||
const expectedPopupItems = [
|
||||
"item3",
|
||||
"item2",
|
||||
"item1",
|
||||
"item0",
|
||||
];
|
||||
|
||||
is(popup.itemCount, expectedPopupItems.length, "popup.itemCount is correct");
|
||||
is(popupItems.join("-"), expectedPopupItems.join("-"),
|
||||
"getItems returns the items we expect");
|
||||
is(popup.selectedIndex, expectedPopupItems.length - 1,
|
||||
"Index of the first item from bottom is selected.");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "item3", "item3 is selected");
|
||||
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
is(popup.selectedIndex, 1, "index 1 is selected");
|
||||
is(popup.selectedItem.label, "item2", "item2 is selected");
|
||||
is(completeNode.value, prefix + "item2", "completeNode.value holds item2");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {});
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "item3", "item3 is selected");
|
||||
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
|
||||
|
||||
let currentSelectionIndex = popup.selectedIndex;
|
||||
|
||||
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
|
||||
|
||||
ok(popup.selectedIndex > currentSelectionIndex, "Index is greater after PGDN");
|
||||
|
||||
currentSelectionIndex = popup.selectedIndex;
|
||||
EventUtils.synthesizeKey("VK_PAGE_UP", {});
|
||||
|
||||
ok(popup.selectedIndex < currentSelectionIndex, "Index is less after Page UP");
|
||||
|
||||
EventUtils.synthesizeKey("VK_END", {});
|
||||
is(popup.selectedIndex, expectedPopupItems.length - 1, "index is last after End");
|
||||
|
||||
EventUtils.synthesizeKey("VK_HOME", {});
|
||||
is(popup.selectedIndex, 0, "index is first after Home");
|
||||
|
||||
info("press Tab and wait for popup to hide");
|
||||
const onPopupClose = popup.once("popup-closed");
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
|
||||
await onPopupClose;
|
||||
|
||||
// At this point the completion suggestion should be accepted.
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
is(jsterm.getInputValue(), "window.foo.item3",
|
||||
"completion was successful after VK_TAB");
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
});
|
|
@ -0,0 +1,86 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 585991.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
/* Create a prototype-less object so popup does not contain native
|
||||
* Object prototype properties.
|
||||
*/
|
||||
window.foobar = Object.create(null);
|
||||
Object.assign(window.foobar, {
|
||||
item0: "value0",
|
||||
item1: "value1",
|
||||
item2: "value2",
|
||||
item3: "value3",
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 585991 - test pressing return with open popup</body>`;
|
||||
|
||||
// We should turn off auto-multiline editing during these tests
|
||||
const PREF_AUTO_MULTILINE = "devtools.webconsole.autoMultiline";
|
||||
|
||||
add_task(async function () {
|
||||
Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, false);
|
||||
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
let onPopUpOpen = popup.once("popup-opened");
|
||||
|
||||
info("wait for completion suggestions: window.foobar.");
|
||||
|
||||
jsterm.setInputValue("window.fooba");
|
||||
EventUtils.synthesizeKey("r", {});
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
|
||||
await onPopUpOpen;
|
||||
|
||||
ok(popup.isOpen, "popup is open");
|
||||
|
||||
const expectedPopupItems = [
|
||||
"item3",
|
||||
"item2",
|
||||
"item1",
|
||||
"item0",
|
||||
];
|
||||
is(popup.itemCount, expectedPopupItems.length, "popup.itemCount is correct");
|
||||
is(popup.selectedIndex, expectedPopupItems.length - 1,
|
||||
"First index from bottom is selected");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "item3", "item3 is selected");
|
||||
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
|
||||
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
|
||||
|
||||
info("press Return to accept suggestion. wait for popup to hide");
|
||||
const onPopupClose = popup.once("popup-closed");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
|
||||
await onPopupClose;
|
||||
|
||||
ok(!popup.isOpen, "popup is not open after VK_RETURN");
|
||||
is(jsterm.getInputValue(), "window.foobar.item3",
|
||||
"completion was successful after VK_RETURN");
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
Services.prefs.clearUserPref(PREF_AUTO_MULTILINE);
|
||||
});
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 873250.
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<head>
|
||||
<script>
|
||||
window.testBugA = "hello world";
|
||||
window.testBugB = "hello world 2";
|
||||
</script>
|
||||
</head>
|
||||
<body>bug 873250 - test pressing return with open popup, but no selection</body>`;
|
||||
|
||||
add_task(async function () {
|
||||
let { jsterm } = await openNewTabAndConsole(TEST_URI);
|
||||
// Clearing history that might have been set in previous tests.
|
||||
await jsterm.clearHistory();
|
||||
|
||||
const {
|
||||
autocompletePopup: popup,
|
||||
completeNode,
|
||||
inputNode,
|
||||
} = jsterm;
|
||||
|
||||
const onPopUpOpen = popup.once("popup-opened");
|
||||
|
||||
info("wait for popup to show");
|
||||
jsterm.setInputValue("window.testBu");
|
||||
EventUtils.synthesizeKey("g", {});
|
||||
|
||||
await onPopUpOpen;
|
||||
|
||||
ok(popup.isOpen, "popup is open");
|
||||
is(popup.itemCount, 2, "popup.itemCount is correct");
|
||||
isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
|
||||
|
||||
info("press Return and wait for popup to hide");
|
||||
const onPopUpClose = popup.once("popup-closed");
|
||||
executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
|
||||
await onPopUpClose;
|
||||
|
||||
ok(!popup.isOpen, "popup is not open after VK_RETURN");
|
||||
is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN");
|
||||
is(completeNode.value, "", "completeNode is empty");
|
||||
is(jsterm.history[jsterm.history.length - 1], "window.testBug",
|
||||
"jsterm history is correct");
|
||||
|
||||
// Cleaning history.
|
||||
await jsterm.clearHistory();
|
||||
});
|
|
@ -1,369 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// See Bug 585991.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,<p>bug 585991 - autocomplete " +
|
||||
"popup keyboard usage test";
|
||||
|
||||
// We should turn off auto-multiline editing during these tests
|
||||
const PREF_AUTO_MULTILINE = "devtools.webconsole.autoMultiline";
|
||||
var HUD, popup, jsterm, inputNode, completeNode;
|
||||
|
||||
add_task(function* () {
|
||||
Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, false);
|
||||
yield loadTab(TEST_URI);
|
||||
let hud = yield openConsole();
|
||||
|
||||
yield consoleOpened(hud);
|
||||
yield popupHideAfterTab();
|
||||
yield testReturnKey();
|
||||
yield dontShowArrayNumbers();
|
||||
yield testReturnWithNoSelection();
|
||||
yield popupHideAfterReturnWithNoSelection();
|
||||
yield testCompletionInText();
|
||||
yield popupHideAfterCompletionInText();
|
||||
|
||||
HUD = popup = jsterm = inputNode = completeNode = null;
|
||||
Services.prefs.setBoolPref(PREF_AUTO_MULTILINE, true);
|
||||
});
|
||||
|
||||
var consoleOpened = Task.async(function* (hud) {
|
||||
let deferred = defer();
|
||||
HUD = hud;
|
||||
info("web console opened");
|
||||
|
||||
jsterm = HUD.jsterm;
|
||||
|
||||
yield jsterm.execute("window.foobarBug585991={" +
|
||||
"'item0': 'value0'," +
|
||||
"'item1': 'value1'," +
|
||||
"'item2': 'value2'," +
|
||||
"'item3': 'value3'" +
|
||||
"}");
|
||||
yield jsterm.execute("window.testBug873250a = 'hello world';"
|
||||
+ "window.testBug873250b = 'hello world 2';");
|
||||
popup = jsterm.autocompletePopup;
|
||||
completeNode = jsterm.completeNode;
|
||||
inputNode = jsterm.inputNode;
|
||||
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
|
||||
popup.once("popup-opened", () => {
|
||||
ok(popup.isOpen, "popup is open");
|
||||
|
||||
// 4 values, and the following properties:
|
||||
// __defineGetter__ __defineSetter__ __lookupGetter__ __lookupSetter__
|
||||
// __proto__ hasOwnProperty isPrototypeOf propertyIsEnumerable
|
||||
// toLocaleString toString toSource unwatch valueOf watch constructor.
|
||||
is(popup.itemCount, 19, "popup.itemCount is correct");
|
||||
|
||||
let sameItems = popup.getItems().reverse().map(function (e) {
|
||||
return e.label;
|
||||
});
|
||||
|
||||
ok(sameItems.every(function (prop, index) {
|
||||
return [
|
||||
"__defineGetter__",
|
||||
"__defineSetter__",
|
||||
"__lookupGetter__",
|
||||
"__lookupSetter__",
|
||||
"__proto__",
|
||||
"constructor",
|
||||
"hasOwnProperty",
|
||||
"isPrototypeOf",
|
||||
"item0",
|
||||
"item1",
|
||||
"item2",
|
||||
"item3",
|
||||
"propertyIsEnumerable",
|
||||
"toLocaleString",
|
||||
"toSource",
|
||||
"toString",
|
||||
"unwatch",
|
||||
"valueOf",
|
||||
"watch",
|
||||
][index] === prop;
|
||||
}), "getItems returns the items we expect");
|
||||
|
||||
is(popup.selectedIndex, 18,
|
||||
"Index of the first item from bottom is selected.");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "watch", "watch is selected");
|
||||
is(completeNode.value, prefix + "watch",
|
||||
"completeNode.value holds watch");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
is(popup.selectedIndex, 1, "index 1 is selected");
|
||||
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
|
||||
is(completeNode.value, prefix + "valueOf",
|
||||
"completeNode.value holds valueOf");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {});
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "watch", "watch is selected");
|
||||
is(completeNode.value, prefix + "watch",
|
||||
"completeNode.value holds watch");
|
||||
|
||||
let currentSelectionIndex = popup.selectedIndex;
|
||||
|
||||
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
|
||||
|
||||
ok(popup.selectedIndex > currentSelectionIndex,
|
||||
"Index is greater after PGDN");
|
||||
|
||||
currentSelectionIndex = popup.selectedIndex;
|
||||
EventUtils.synthesizeKey("VK_PAGE_UP", {});
|
||||
|
||||
ok(popup.selectedIndex < currentSelectionIndex,
|
||||
"Index is less after Page UP");
|
||||
|
||||
EventUtils.synthesizeKey("VK_END", {});
|
||||
is(popup.selectedIndex, 18, "index is last after End");
|
||||
|
||||
EventUtils.synthesizeKey("VK_HOME", {});
|
||||
is(popup.selectedIndex, 0, "index is first after Home");
|
||||
|
||||
info("press Tab and wait for popup to hide");
|
||||
popup.once("popup-closed", () => {
|
||||
deferred.resolve();
|
||||
});
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
});
|
||||
|
||||
jsterm.setInputValue("window.foobarBug585991");
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
|
||||
return deferred.promise;
|
||||
});
|
||||
|
||||
function popupHideAfterTab() {
|
||||
let deferred = defer();
|
||||
|
||||
// At this point the completion suggestion should be accepted.
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
|
||||
is(jsterm.getInputValue(), "window.foobarBug585991.watch",
|
||||
"completion was successful after VK_TAB");
|
||||
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
popup.once("popup-opened", function onShown() {
|
||||
ok(popup.isOpen, "popup is open");
|
||||
|
||||
is(popup.itemCount, 19, "popup.itemCount is correct");
|
||||
|
||||
is(popup.selectedIndex, 18, "First index from bottom is selected");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "watch", "watch is selected");
|
||||
is(completeNode.value, prefix + "watch",
|
||||
"completeNode.value holds watch");
|
||||
|
||||
popup.once("popup-closed", function onHidden() {
|
||||
ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
|
||||
|
||||
is(jsterm.getInputValue(), "window.foobarBug585991.",
|
||||
"completion was cancelled");
|
||||
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
deferred.resolve();
|
||||
}, false);
|
||||
|
||||
info("press Escape to close the popup");
|
||||
executeSoon(function () {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
});
|
||||
}, false);
|
||||
|
||||
info("wait for completion: window.foobarBug585991.");
|
||||
executeSoon(function () {
|
||||
jsterm.setInputValue("window.foobarBug585991");
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testReturnKey() {
|
||||
let deferred = defer();
|
||||
|
||||
popup.once("popup-opened", function onShown() {
|
||||
ok(popup.isOpen, "popup is open");
|
||||
|
||||
is(popup.itemCount, 19, "popup.itemCount is correct");
|
||||
|
||||
is(popup.selectedIndex, 18, "First index from bottom is selected");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
|
||||
|
||||
is(popup.selectedIndex, 0, "index 0 is selected");
|
||||
is(popup.selectedItem.label, "watch", "watch is selected");
|
||||
is(completeNode.value, prefix + "watch",
|
||||
"completeNode.value holds watch");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
||||
is(popup.selectedIndex, 1, "index 1 is selected");
|
||||
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
|
||||
is(completeNode.value, prefix + "valueOf",
|
||||
"completeNode.value holds valueOf");
|
||||
|
||||
popup.once("popup-closed", function onHidden() {
|
||||
ok(!popup.isOpen, "popup is not open after VK_RETURN");
|
||||
|
||||
is(jsterm.getInputValue(), "window.foobarBug585991.valueOf",
|
||||
"completion was successful after VK_RETURN");
|
||||
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
deferred.resolve();
|
||||
}, false);
|
||||
|
||||
info("press Return to accept suggestion. wait for popup to hide");
|
||||
|
||||
executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
|
||||
}, false);
|
||||
|
||||
info("wait for completion suggestions: window.foobarBug585991.");
|
||||
|
||||
executeSoon(function () {
|
||||
jsterm.setInputValue("window.foobarBug58599");
|
||||
EventUtils.synthesizeKey("1", {});
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function* dontShowArrayNumbers() {
|
||||
let deferred = defer();
|
||||
|
||||
info("dontShowArrayNumbers");
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.foobarBug585991 = ["Sherlock Holmes"];
|
||||
});
|
||||
|
||||
jsterm = HUD.jsterm;
|
||||
popup = jsterm.autocompletePopup;
|
||||
|
||||
popup.once("popup-opened", function onShown() {
|
||||
let sameItems = popup.getItems().map(function (e) {
|
||||
return e.label;
|
||||
});
|
||||
ok(!sameItems.some(function (prop) {
|
||||
prop === "0";
|
||||
}), "Completing on an array doesn't show numbers.");
|
||||
|
||||
popup.once("popup-closed", function popupHidden() {
|
||||
deferred.resolve();
|
||||
}, false);
|
||||
|
||||
info("wait for popup to hide");
|
||||
executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {}));
|
||||
}, false);
|
||||
|
||||
info("wait for popup to show");
|
||||
executeSoon(() => {
|
||||
jsterm.setInputValue("window.foobarBug585991");
|
||||
EventUtils.synthesizeKey(".", {});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testReturnWithNoSelection() {
|
||||
let deferred = defer();
|
||||
|
||||
info("test pressing return with open popup, but no selection, see bug 873250");
|
||||
|
||||
popup.once("popup-opened", function onShown() {
|
||||
ok(popup.isOpen, "popup is open");
|
||||
is(popup.itemCount, 2, "popup.itemCount is correct");
|
||||
isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
|
||||
|
||||
info("press Return and wait for popup to hide");
|
||||
popup.once("popup-closed", function popupHidden() {
|
||||
deferred.resolve();
|
||||
});
|
||||
executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
|
||||
});
|
||||
|
||||
executeSoon(() => {
|
||||
info("wait for popup to show");
|
||||
jsterm.setInputValue("window.testBu");
|
||||
EventUtils.synthesizeKey("g", {});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function popupHideAfterReturnWithNoSelection() {
|
||||
ok(!popup.isOpen, "popup is not open after VK_RETURN");
|
||||
|
||||
is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN");
|
||||
is(completeNode.value, "", "completeNode is empty");
|
||||
is(jsterm.history[jsterm.history.length - 1], "window.testBug",
|
||||
"jsterm history is correct");
|
||||
|
||||
return promise.resolve();
|
||||
}
|
||||
|
||||
function testCompletionInText() {
|
||||
info("test that completion works inside text, see bug 812618");
|
||||
|
||||
let deferred = defer();
|
||||
|
||||
popup.once("popup-opened", function onShown() {
|
||||
ok(popup.isOpen, "popup is open");
|
||||
is(popup.itemCount, 2, "popup.itemCount is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
|
||||
ok(!completeNode.value, "completeNode.value is empty");
|
||||
|
||||
let items = popup.getItems().reverse().map(e => e.label);
|
||||
let sameItems = items.every((prop, index) =>
|
||||
["testBug873250a", "testBug873250b"][index] === prop);
|
||||
ok(sameItems, "getItems returns the items we expect");
|
||||
|
||||
info("press Tab and wait for popup to hide");
|
||||
popup.once("popup-closed", function popupHidden() {
|
||||
deferred.resolve();
|
||||
});
|
||||
EventUtils.synthesizeKey("VK_TAB", {});
|
||||
});
|
||||
|
||||
jsterm.setInputValue("dump(window.testBu)");
|
||||
inputNode.selectionStart = inputNode.selectionEnd = 18;
|
||||
EventUtils.synthesizeKey("g", {});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function popupHideAfterCompletionInText() {
|
||||
// At this point the completion suggestion should be accepted.
|
||||
ok(!popup.isOpen, "popup is not open");
|
||||
is(jsterm.getInputValue(), "dump(window.testBug873250b)",
|
||||
"completion was successful after VK_TAB");
|
||||
is(inputNode.selectionStart, 26, "cursor location is correct");
|
||||
is(inputNode.selectionStart, inputNode.selectionEnd,
|
||||
"cursor location (confirmed)");
|
||||
ok(!completeNode.value, "completeNode is empty");
|
||||
|
||||
return promise.resolve();
|
||||
}
|
Загрузка…
Ссылка в новой задаче