Bug 1616796 - Use 'getAutocompletePopupLabels' function in webconsole tests r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D63789

--HG--
extra : moz-landing-system : lando
This commit is contained in:
agamvrinos 2020-02-24 10:30:20 +00:00
Родитель 8a542e1a3b
Коммит f5351d6f7d
17 изменённых файлов: 35 добавлений и 77 удалений

Просмотреть файл

@ -25,7 +25,7 @@ add_task(async function() {
await onPopUpOpen;
const popupItems = popup.getItems().map(e => e.label);
const popupItems = getAutocompletePopupLabels(popup);
is(
popupItems.includes("0"),
false,

Просмотреть файл

@ -36,7 +36,7 @@ add_task(async function() {
EventUtils.synthesizeKey("d");
await onUpdated;
ok(
!getPopupLabels(popup).includes("docfoobar"),
!getAutocompletePopupLabels(popup).includes("docfoobar"),
"autocomplete popup does not contain docfoobar. List has not been updated"
);
@ -45,7 +45,7 @@ add_task(async function() {
EventUtils.synthesizeKey("o");
await onUpdated;
ok(
!getPopupLabels(popup).includes("docfoobar"),
!getAutocompletePopupLabels(popup).includes("docfoobar"),
"autocomplete popup does not contain docfoobar. List has not been updated"
);
@ -54,7 +54,7 @@ add_task(async function() {
EventUtils.synthesizeKey("KEY_Backspace");
await onUpdated;
ok(
!getPopupLabels(popup).includes("docfoobar"),
!getAutocompletePopupLabels(popup).includes("docfoobar"),
"autocomplete cached results do not contain docfoobar. list has not been updated"
);
@ -66,7 +66,7 @@ add_task(async function() {
await jstermComplete("window.");
await jstermComplete("window.getC");
ok(
getPopupLabels(popup).includes("getComputedStyle"),
getAutocompletePopupLabels(popup).includes("getComputedStyle"),
"autocomplete results do contain getComputedStyle"
);
@ -92,7 +92,7 @@ add_task(async function() {
await onUpdated;
ok(
!getPopupLabels(popup).includes("docfoobar"),
!getAutocompletePopupLabels(popup).includes("docfoobar"),
"autocomplete cached results do not contain docfoobar. list has not been updated"
);
@ -109,7 +109,7 @@ add_task(async function() {
await jstermComplete("window.testObject.");
await jstermComplete("window.testObject.z");
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"zz-zzz-zzzz",
"results are the expected ones"
);
@ -118,7 +118,7 @@ add_task(async function() {
EventUtils.sendString("z");
await onUpdated;
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"zz-zzz-zzzz",
"filtering from the cache works - step 1"
);
@ -127,12 +127,8 @@ add_task(async function() {
EventUtils.sendString("z");
await onUpdated;
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"zzz-zzzz",
"filtering from the cache works - step 2"
);
});
function getPopupLabels(popup) {
return popup.getItems().map(item => item.label);
}

Просмотреть файл

@ -22,7 +22,7 @@ add_task(async function() {
const expectedCommands = [":help", ":screenshot"];
is(
getPopupItems(autocompletePopup).join("\n"),
getAutocompletePopupLabels(autocompletePopup).join("\n"),
expectedCommands.join("\n"),
"popup contains expected commands"
);
@ -62,7 +62,3 @@ add_task(async function() {
EventUtils.synthesizeKey("KEY_Tab");
is(getInputValue(hud), ":help", "Tab key correctly completes :help");
});
function getPopupItems(popup) {
return popup.items.map(item => item.label);
}

Просмотреть файл

@ -28,7 +28,7 @@ add_task(async function() {
);
is(
getPopupLabels(autocompletePopup).join("\n"),
getAutocompletePopupLabels(autocompletePopup).join("\n"),
[
"testClass",
"testConst",
@ -47,7 +47,3 @@ add_task(async function() {
"Autocomplete popup displays both global and local variables"
);
});
function getPopupLabels(popup) {
return popup.getItems().map(item => item.label);
}

Просмотреть файл

@ -25,14 +25,10 @@ async function testInspectAutoCompletion(hud, inputValue, expectInspect) {
EventUtils.sendString(inputValue);
await updated;
is(
getPopupItemsLabel(jsterm.autocompletePopup).includes("inspect"),
getAutocompletePopupLabels(jsterm.autocompletePopup).includes("inspect"),
expectInspect,
`autocomplete results${
expectInspect ? "" : " does not"
} contain helper 'inspect'`
);
}
function getPopupItemsLabel(popup) {
return popup.getItems().map(item => item.label);
}

Просмотреть файл

@ -26,7 +26,7 @@ add_task(async function() {
// Test that document.title gives string methods. Native getters must execute.
await jstermComplete("document.title.");
const newItemsLabels = getPopupLabels(popup);
const newItemsLabels = getAutocompletePopupLabels(popup);
ok(newItemsLabels.length > 0, "'document.title.' gave a list of suggestions");
ok(newItemsLabels.includes("substr"), `results do contain "substr"`);
ok(
@ -38,7 +38,7 @@ add_task(async function() {
// Test if 'foo' gives 'foo1' but not 'foo2' or 'foo3'
await jstermComplete("foo");
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"foo1-foo1Obj",
`"foo" gave the expected suggestions`
);
@ -47,7 +47,7 @@ add_task(async function() {
await jstermComplete("foo1Obj.");
checkInputCompletionValue(hud, "prop1", "foo1Obj completion");
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"prop1-prop2",
`"foo1Obj." gave the expected suggestions`
);
@ -55,7 +55,7 @@ add_task(async function() {
// Test if 'foo1Obj.prop2.' gives 'prop21'
await jstermComplete("foo1Obj.prop2.");
ok(
getPopupLabels(popup).includes("prop21"),
getAutocompletePopupLabels(popup).includes("prop21"),
`"foo1Obj.prop2." gave the expected suggestions`
);
@ -74,7 +74,7 @@ add_task(async function() {
// the `secondCall` function (called by `firstCall`, which we call in `pauseDebugger`).
await jstermComplete("foo");
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"foo1-foo1Obj-foo3-foo3Obj",
`"foo" gave the expected suggestions`
);
@ -91,31 +91,33 @@ add_task(async function() {
// `firstCall` frame.
await jstermComplete("foo");
is(
getPopupLabels(popup).join("-"),
getAutocompletePopupLabels(popup).join("-"),
"foo1-foo1Obj-foo2-foo2Obj",
`"foo" gave the expected suggestions`
);
// Test if 'foo2Obj.' gives 'prop1'
await jstermComplete("foo2Obj.");
ok(getPopupLabels(popup).includes("prop1"), `"foo2Obj." returns "prop1"`);
ok(
getAutocompletePopupLabels(popup).includes("prop1"),
`"foo2Obj." returns "prop1"`
);
// Test if 'foo2Obj.prop1.' gives 'prop11'
await jstermComplete("foo2Obj.prop1.");
ok(
getPopupLabels(popup).includes("prop11"),
getAutocompletePopupLabels(popup).includes("prop11"),
`"foo2Obj.prop1" returns "prop11"`
);
// Test if 'foo2Obj.prop1.prop11.' gives suggestions for a string,i.e. 'length'
await jstermComplete("foo2Obj.prop1.prop11.");
ok(getPopupLabels(popup).includes("length"), `results do contain "length"`);
ok(
getAutocompletePopupLabels(popup).includes("length"),
`results do contain "length"`
);
// Test if 'foo2Obj[0].' throws no errors.
await jstermComplete("foo2Obj[0].");
is(getPopupLabels(popup).length, 0, "no items for foo2Obj[0]");
is(getAutocompletePopupLabels(popup).length, 0, "no items for foo2Obj[0]");
});
function getPopupLabels(popup) {
return popup.getItems().map(item => item.label);
}

Просмотреть файл

@ -50,7 +50,7 @@ add_task(async function() {
is(popup.selectedIndex, 1, "popup.selectedIndex is correct");
ok(!getInputCompletionValue(hud), "completeNode.value is empty");
const items = popup.getItems().map(e => e.label);
const items = getAutocompletePopupLabels(popup);
const expectedItems = ["testBugAA", "testBugBB"];
is(
items.join("-"),

Просмотреть файл

@ -39,7 +39,7 @@ add_task(async function() {
ok(popup.isOpen, "popup is open");
const popupItems = popup.getItems().map(e => e.label);
const popupItems = getAutocompletePopupLabels(popup);
const expectedPopupItems = ["item00", "item1", "item2", "item3"];
is(popup.itemCount, expectedPopupItems.length, "popup.itemCount is correct");

Просмотреть файл

@ -29,7 +29,7 @@ add_task(async function() {
ok(popup.isOpen, "popup is open");
const expectedPopupItems = ["null", "nullVar"];
is(
popup.items.map(i => i.label).join("-"),
getAutocompletePopupLabels(popup).join("-"),
expectedPopupItems.join("-"),
"popup has expected items"
);

Просмотреть файл

@ -31,7 +31,7 @@ add_task(async function() {
const expectedPopupItems = ["xx", "xxx"];
is(
popup.items.map(i => i.label).join("-"),
getAutocompletePopupLabels(popup).join("-"),
expectedPopupItems.join("-"),
"popup has expected items"
);

Просмотреть файл

@ -233,7 +233,3 @@ async function testAcceptCompletionExistingClosingBracket(hud) {
`input was completed as expected, without adding a closing bracket`
);
}
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -129,7 +129,3 @@ add_task(async function() {
setInputValue(hud, "");
}
});
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -122,7 +122,3 @@ add_task(async function() {
"popup was filtered case-sensitively, as expected"
);
});
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -55,7 +55,3 @@ add_task(async function() {
"autocomplete popup has expected items"
);
});
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -46,7 +46,3 @@ add_task(async function() {
"autocomplete popup has expected items"
);
});
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -39,7 +39,3 @@ add_task(async function() {
"popup has expected item, in expected order"
);
});
function getAutocompletePopupLabels(autocompletePopup) {
return autocompletePopup.items.map(i => i.label);
}

Просмотреть файл

@ -40,9 +40,9 @@ add_task(async function() {
for (const helper of HELPERS) {
await setInputValueForAutocompletion(hud, helper);
const autocompleteItems = getPopupLabels(autocompletePopup).filter(
l => l === helper
);
const autocompleteItems = getAutocompletePopupLabels(
autocompletePopup
).filter(l => l === helper);
is(
autocompleteItems.length,
1,
@ -58,7 +58,3 @@ add_task(async function() {
ok(true, `output is correct for ${helper}()`);
}
});
function getPopupLabels(popup) {
return popup.getItems().map(item => item.label);
}