mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 09:49:14 +00:00
Bug 1275081 - Part 1: Remove hardcoded number of "displayed" suggestions in devtools tests. r=tromey
Several devtools autocomplete tests are checking that the popup displays an exact number of suggestion, and that the selected suggestion is exactly at the expected index. Since devtools do not control the list of CSS properties used for the autocomplete, we should not assert anything based on it in tests. MozReview-Commit-ID: H4Azyx0UgpX --HG-- extra : transplant_source : r%E1%10k%AF%88%98%CD%C6_fV%99w%FA%E8%F6G%3A%25
This commit is contained in:
parent
4c2cce623c
commit
cfdf369a02
@ -11,57 +11,59 @@
|
||||
// [
|
||||
// what key to press,
|
||||
// expected input box value after keypress,
|
||||
// selectedIndex of the popup,
|
||||
// total items in the popup
|
||||
// is the popup open,
|
||||
// is a suggestion selected in the popup,
|
||||
// ]
|
||||
|
||||
const OPEN = true, SELECTED = true;
|
||||
var testData = [
|
||||
["VK_RIGHT", "font", -1, 0],
|
||||
["-", "font-size", 4, 17],
|
||||
["f", "font-family", 0, 2],
|
||||
["VK_BACK_SPACE", "font-f", -1, 0],
|
||||
["VK_BACK_SPACE", "font-", -1, 0],
|
||||
["VK_BACK_SPACE", "font", -1, 0],
|
||||
["VK_BACK_SPACE", "fon", -1, 0],
|
||||
["VK_BACK_SPACE", "fo", -1, 0],
|
||||
["VK_BACK_SPACE", "f", -1, 0],
|
||||
["VK_BACK_SPACE", "", -1, 0],
|
||||
["d", "display", 1, 3],
|
||||
["VK_DOWN", "dominant-baseline", 2, 3],
|
||||
["VK_DOWN", "direction", 0, 3],
|
||||
["VK_DOWN", "display", 1, 3],
|
||||
["VK_UP", "direction", 0, 3],
|
||||
["VK_UP", "dominant-baseline", 2, 3],
|
||||
["VK_UP", "display", 1, 3],
|
||||
["VK_BACK_SPACE", "d", -1, 0],
|
||||
["i", "display", 1, 2],
|
||||
["s", "display", -1, 0],
|
||||
["VK_BACK_SPACE", "dis", -1, 0],
|
||||
["VK_BACK_SPACE", "di", -1, 0],
|
||||
["VK_BACK_SPACE", "d", -1, 0],
|
||||
["VK_BACK_SPACE", "", -1, 0],
|
||||
["VK_HOME", "", -1, 0],
|
||||
["VK_END", "", -1, 0],
|
||||
["VK_PAGE_UP", "", -1, 0],
|
||||
["VK_PAGE_DOWN", "", -1, 0],
|
||||
["d", "display", 1, 3],
|
||||
["VK_HOME", "display", -1, 0],
|
||||
["VK_END", "display", -1, 0],
|
||||
["VK_RIGHT", "font", !OPEN, !SELECTED],
|
||||
["-", "font-size", OPEN, SELECTED],
|
||||
["f", "font-family", OPEN, SELECTED],
|
||||
["VK_BACK_SPACE", "font-f", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "font-", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "font", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "fon", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "fo", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "f", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "", !OPEN, !SELECTED],
|
||||
["d", "display", OPEN, SELECTED],
|
||||
["VK_DOWN", "dominant-baseline", OPEN, SELECTED],
|
||||
["VK_DOWN", "direction", OPEN, SELECTED],
|
||||
["VK_DOWN", "display", OPEN, SELECTED],
|
||||
["VK_UP", "direction", OPEN, SELECTED],
|
||||
["VK_UP", "dominant-baseline", OPEN, SELECTED],
|
||||
["VK_UP", "display", OPEN, SELECTED],
|
||||
["VK_BACK_SPACE", "d", !OPEN, !SELECTED],
|
||||
["i", "display", OPEN, SELECTED],
|
||||
["s", "display", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "dis", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "di", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "d", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "", !OPEN, !SELECTED],
|
||||
["VK_HOME", "", !OPEN, !SELECTED],
|
||||
["VK_END", "", !OPEN, !SELECTED],
|
||||
["VK_PAGE_UP", "", !OPEN, !SELECTED],
|
||||
["VK_PAGE_DOWN", "", !OPEN, !SELECTED],
|
||||
["d", "display", OPEN, SELECTED],
|
||||
["VK_HOME", "display", !OPEN, !SELECTED],
|
||||
["VK_END", "display", !OPEN, !SELECTED],
|
||||
// Press right key to ensure caret move to end of the input on Mac OS since
|
||||
// Mac OS doesn't move caret after pressing HOME / END.
|
||||
["VK_RIGHT", "display", -1, 0],
|
||||
["VK_BACK_SPACE", "displa", -1, 0],
|
||||
["VK_BACK_SPACE", "displ", -1, 0],
|
||||
["VK_BACK_SPACE", "disp", -1, 0],
|
||||
["VK_BACK_SPACE", "dis", -1, 0],
|
||||
["VK_BACK_SPACE", "di", -1, 0],
|
||||
["VK_BACK_SPACE", "d", -1, 0],
|
||||
["VK_BACK_SPACE", "", -1, 0],
|
||||
["f", "font-size", 19, 32],
|
||||
["i", "filter", 3, 4],
|
||||
["VK_LEFT", "filter", -1, 0],
|
||||
["VK_LEFT", "filter", -1, 0],
|
||||
["i", "fiilter", -1, 0],
|
||||
["VK_ESCAPE", null, -1, 0],
|
||||
["VK_RIGHT", "display", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "displa", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "displ", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "disp", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "dis", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "di", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "d", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "", !OPEN, !SELECTED],
|
||||
["f", "font-size", OPEN, SELECTED],
|
||||
["i", "filter", OPEN, SELECTED],
|
||||
["VK_LEFT", "filter", !OPEN, !SELECTED],
|
||||
["VK_LEFT", "filter", !OPEN, !SELECTED],
|
||||
["i", "fiilter", !OPEN, !SELECTED],
|
||||
["VK_ESCAPE", null, !OPEN, !SELECTED],
|
||||
];
|
||||
|
||||
const TEST_URI = "<h1 style='font: 24px serif'>Header</h1>";
|
||||
@ -96,10 +98,12 @@ function* runAutocompletionTest(toolbox, inspector, view) {
|
||||
}
|
||||
}
|
||||
|
||||
function* testCompletion([key, completion, index, total],
|
||||
function* testCompletion([key, completion, open, selected],
|
||||
expectPopupHiddenEvent, editor, view) {
|
||||
info("Pressing key " + key);
|
||||
info("Expecting " + completion + ", " + index + ", " + total);
|
||||
info("Expecting " + completion);
|
||||
info("Is popup opened: " + open);
|
||||
info("Is item selected: " + selected);
|
||||
|
||||
// Listening for the right event that will tell us when the key has been
|
||||
// entered and processed.
|
||||
@ -128,12 +132,11 @@ function* testCompletion([key, completion, index, total],
|
||||
if (completion != null) {
|
||||
is(editor.input.value, completion, "Correct value is autocompleted");
|
||||
}
|
||||
if (total == 0) {
|
||||
if (!open) {
|
||||
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
|
||||
} else {
|
||||
ok(editor.popup._panel.state == "open" ||
|
||||
editor.popup._panel.state == "showing", "Popup is open");
|
||||
is(editor.popup.getItems().length, total, "Number of suggestions match");
|
||||
is(editor.popup.selectedIndex, index, "Correct item is selected");
|
||||
is(editor.popup.selectedIndex != -1, selected, "An item is selected");
|
||||
}
|
||||
}
|
||||
|
@ -12,27 +12,29 @@
|
||||
// what key to press,
|
||||
// modifers,
|
||||
// expected input box value after keypress,
|
||||
// selectedIndex of the popup,
|
||||
// total items in the popup,
|
||||
// expect ruleview-changed
|
||||
// is the popup open,
|
||||
// is a suggestion selected in the popup,
|
||||
// expect ruleview-changed,
|
||||
// ]
|
||||
|
||||
const OPEN = true, SELECTED = true, CHANGE = true;
|
||||
var testData = [
|
||||
["b", {}, "beige", 0, 8, true],
|
||||
["l", {}, "black", 0, 4, true],
|
||||
["VK_DOWN", {}, "blanchedalmond", 1, 4, true],
|
||||
["VK_DOWN", {}, "blue", 2, 4, true],
|
||||
["VK_RIGHT", {}, "blue", -1, 0, false],
|
||||
[" ", {}, "blue aliceblue", 0, 158, true],
|
||||
["!", {}, "blue !important", 0, 0, true],
|
||||
["VK_BACK_SPACE", {}, "blue !", -1, 0, true],
|
||||
["VK_BACK_SPACE", {}, "blue ", -1, 0, true],
|
||||
["VK_BACK_SPACE", {}, "blue", -1, 0, true],
|
||||
["VK_TAB", {shiftKey: true}, "color", -1, 0, true],
|
||||
["VK_BACK_SPACE", {}, "", -1, 0, false],
|
||||
["d", {}, "display", 1, 3, false],
|
||||
["VK_TAB", {}, "blue", -1, 0, true],
|
||||
["n", {}, "none", -1, 0, true],
|
||||
["VK_RETURN", {}, null, -1, 0, true]
|
||||
["b", {}, "beige", OPEN, SELECTED, CHANGE],
|
||||
["l", {}, "black", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "blanchedalmond", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "blue", OPEN, SELECTED, CHANGE],
|
||||
["VK_RIGHT", {}, "blue", !OPEN, !SELECTED, !CHANGE],
|
||||
[" ", {}, "blue aliceblue", OPEN, SELECTED, CHANGE],
|
||||
["!", {}, "blue !important", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_BACK_SPACE", {}, "blue !", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_BACK_SPACE", {}, "blue ", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_BACK_SPACE", {}, "blue", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_TAB", {shiftKey: true}, "color", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_BACK_SPACE", {}, "", !OPEN, !SELECTED, !CHANGE],
|
||||
["d", {}, "display", OPEN, SELECTED, !CHANGE],
|
||||
["VK_TAB", {}, "blue", !OPEN, !SELECTED, CHANGE],
|
||||
["n", {}, "none", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_RETURN", {}, null, !OPEN, !SELECTED, CHANGE]
|
||||
];
|
||||
|
||||
const TEST_URI = "<h1 style='color: red'>Header</h1>";
|
||||
@ -68,13 +70,15 @@ function* runAutocompletionTest(toolbox, inspector, view) {
|
||||
}
|
||||
}
|
||||
|
||||
function* testCompletion([key, modifiers, completion, index, total, willChange],
|
||||
function* testCompletion([key, modifiers, completion, open, selected, change],
|
||||
editor, view) {
|
||||
info("Pressing key " + key);
|
||||
info("Expecting " + completion + ", " + index + ", " + total);
|
||||
info("Expecting " + completion);
|
||||
info("Is popup opened: " + open);
|
||||
info("Is item selected: " + selected);
|
||||
|
||||
let onDone;
|
||||
if (willChange) {
|
||||
if (change) {
|
||||
// If the key triggers a ruleview-changed, wait for that event, it will
|
||||
// always be the last to be triggered and tells us when the preview has
|
||||
// been done.
|
||||
@ -99,12 +103,12 @@ function* testCompletion([key, modifiers, completion, index, total, willChange],
|
||||
if (completion != null) {
|
||||
is(editor.input.value, completion, "Correct value is autocompleted");
|
||||
}
|
||||
if (total == 0) {
|
||||
|
||||
if (!open) {
|
||||
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
|
||||
} else {
|
||||
ok(editor.popup._panel.state == "open" ||
|
||||
editor.popup._panel.state == "showing", "Popup is open");
|
||||
is(editor.popup.getItems().length, total, "Number of suggestions match");
|
||||
is(editor.popup.selectedIndex, index, "Correct item is selected");
|
||||
is(editor.popup.selectedIndex != -1, selected, "An item is selected");
|
||||
}
|
||||
}
|
||||
|
@ -11,27 +11,28 @@
|
||||
// [
|
||||
// what key to press,
|
||||
// expected input box value after keypress,
|
||||
// selectedIndex of the popup,
|
||||
// total items in the popup
|
||||
// is the popup open,
|
||||
// is a suggestion selected in the popup,
|
||||
// ]
|
||||
const OPEN = true, SELECTED = true;
|
||||
var testData = [
|
||||
["d", "display", 1, 3],
|
||||
["VK_DOWN", "dominant-baseline", 2, 3],
|
||||
["VK_DOWN", "direction", 0, 3],
|
||||
["VK_DOWN", "display", 1, 3],
|
||||
["VK_UP", "direction", 0, 3],
|
||||
["VK_UP", "dominant-baseline", 2, 3],
|
||||
["VK_UP", "display", 1, 3],
|
||||
["VK_BACK_SPACE", "d", -1, 0],
|
||||
["i", "display", 1, 2],
|
||||
["s", "display", -1, 0],
|
||||
["VK_BACK_SPACE", "dis", -1, 0],
|
||||
["VK_BACK_SPACE", "di", -1, 0],
|
||||
["VK_BACK_SPACE", "d", -1, 0],
|
||||
["VK_BACK_SPACE", "", -1, 0],
|
||||
["f", "font-size", 19, 32],
|
||||
["i", "filter", 3, 4],
|
||||
["VK_ESCAPE", null, -1, 0],
|
||||
["d", "display", OPEN, SELECTED],
|
||||
["VK_DOWN", "dominant-baseline", OPEN, SELECTED],
|
||||
["VK_DOWN", "direction", OPEN, SELECTED],
|
||||
["VK_DOWN", "display", OPEN, SELECTED],
|
||||
["VK_UP", "direction", OPEN, SELECTED],
|
||||
["VK_UP", "dominant-baseline", OPEN, SELECTED],
|
||||
["VK_UP", "display", OPEN, SELECTED],
|
||||
["VK_BACK_SPACE", "d", !OPEN, !SELECTED],
|
||||
["i", "display", OPEN, SELECTED],
|
||||
["s", "display", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "dis", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "di", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "d", !OPEN, !SELECTED],
|
||||
["VK_BACK_SPACE", "", !OPEN, !SELECTED],
|
||||
["f", "font-size", OPEN, SELECTED],
|
||||
["i", "filter", OPEN, SELECTED],
|
||||
["VK_ESCAPE", null, !OPEN, !SELECTED],
|
||||
];
|
||||
|
||||
const TEST_URI = "<h1 style='border: 1px solid red'>Header</h1>";
|
||||
@ -62,9 +63,11 @@ function* runAutocompletionTest(toolbox, inspector, view) {
|
||||
}
|
||||
}
|
||||
|
||||
function* testCompletion([key, completion, index, total], editor, view) {
|
||||
function* testCompletion([key, completion, isOpen, isSelected], editor, view) {
|
||||
info("Pressing key " + key);
|
||||
info("Expecting " + completion + ", " + index + ", " + total);
|
||||
info("Expecting " + completion);
|
||||
info("Is popup opened: " + isOpen);
|
||||
info("Is item selected: " + isSelected);
|
||||
|
||||
let onSuggest;
|
||||
|
||||
@ -86,12 +89,11 @@ function* testCompletion([key, completion, index, total], editor, view) {
|
||||
if (completion != null) {
|
||||
is(editor.input.value, completion, "Correct value is autocompleted");
|
||||
}
|
||||
if (total == 0) {
|
||||
if (!isOpen) {
|
||||
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
|
||||
} else {
|
||||
ok(editor.popup._panel.state == "open" ||
|
||||
editor.popup._panel.state == "showing", "Popup is open");
|
||||
is(editor.popup.getItems().length, total, "Number of suggestions match");
|
||||
is(editor.popup.selectedIndex, index, "Correct item is selected");
|
||||
is(editor.popup.selectedIndex != -1, isSelected, "An item is selected");
|
||||
}
|
||||
}
|
||||
|
@ -12,31 +12,33 @@
|
||||
// what key to press,
|
||||
// modifers,
|
||||
// expected input box value after keypress,
|
||||
// selectedIndex of the popup,
|
||||
// total items in the popup,
|
||||
// expect ruleview-changed
|
||||
// is the popup open,
|
||||
// is a suggestion selected in the popup,
|
||||
// expect ruleview-changed,
|
||||
// ]
|
||||
var testData = [
|
||||
["d", {}, "display", 1, 3, false],
|
||||
["VK_TAB", {}, "", -1, 43, true],
|
||||
["VK_DOWN", {}, "block", 0, 43, true],
|
||||
["n", {}, "none", -1, 0, true],
|
||||
["VK_TAB", {shiftKey: true}, "display", -1, 0, true],
|
||||
["VK_BACK_SPACE", {}, "", -1, 0, false],
|
||||
["o", {}, "overflow", 13, 17, false],
|
||||
["u", {}, "outline", 0, 5, false],
|
||||
["VK_DOWN", {}, "outline-color", 1, 5, false],
|
||||
["VK_TAB", {}, "none", -1, 0, true],
|
||||
["r", {}, "rebeccapurple", 0, 6, true],
|
||||
["VK_DOWN", {}, "red", 1, 6, true],
|
||||
["VK_DOWN", {}, "rgb", 2, 6, true],
|
||||
["VK_DOWN", {}, "rgba", 3, 6, true],
|
||||
["VK_DOWN", {}, "rosybrown", 4, 6, true],
|
||||
["VK_DOWN", {}, "royalblue", 5, 6, true],
|
||||
["VK_RIGHT", {}, "royalblue", -1, 0, false],
|
||||
[" ", {}, "royalblue aliceblue", 0, 159, true],
|
||||
["!", {}, "royalblue !important", 0, 0, true],
|
||||
["VK_ESCAPE", {}, null, -1, 0, true]
|
||||
|
||||
const OPEN = true, SELECTED = true, CHANGE = true;
|
||||
const testData = [
|
||||
["d", {}, "display", OPEN, SELECTED, !CHANGE],
|
||||
["VK_TAB", {}, "", OPEN, !SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "block", OPEN, SELECTED, CHANGE],
|
||||
["n", {}, "none", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_TAB", {shiftKey: true}, "display", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_BACK_SPACE", {}, "", !OPEN, !SELECTED, !CHANGE],
|
||||
["o", {}, "overflow", OPEN, SELECTED, !CHANGE],
|
||||
["u", {}, "outline", OPEN, SELECTED, !CHANGE],
|
||||
["VK_DOWN", {}, "outline-color", OPEN, SELECTED, !CHANGE],
|
||||
["VK_TAB", {}, "none", !OPEN, !SELECTED, CHANGE],
|
||||
["r", {}, "rebeccapurple", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "red", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "rgb", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "rgba", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "rosybrown", OPEN, SELECTED, CHANGE],
|
||||
["VK_DOWN", {}, "royalblue", OPEN, SELECTED, CHANGE],
|
||||
["VK_RIGHT", {}, "royalblue", !OPEN, !SELECTED, !CHANGE],
|
||||
[" ", {}, "royalblue aliceblue", OPEN, SELECTED, CHANGE],
|
||||
["!", {}, "royalblue !important", !OPEN, !SELECTED, CHANGE],
|
||||
["VK_ESCAPE", {}, null, !OPEN, !SELECTED, CHANGE]
|
||||
];
|
||||
|
||||
const TEST_URI = `
|
||||
@ -77,13 +79,15 @@ function* runAutocompletionTest(toolbox, inspector, view) {
|
||||
}
|
||||
}
|
||||
|
||||
function* testCompletion([key, modifiers, completion, index, total, willChange],
|
||||
function* testCompletion([key, modifiers, completion, open, selected, change],
|
||||
editor, view) {
|
||||
info("Pressing key " + key);
|
||||
info("Expecting " + completion + ", " + index + ", " + total);
|
||||
info("Expecting " + completion);
|
||||
info("Is popup opened: " + open);
|
||||
info("Is item selected: " + selected);
|
||||
|
||||
let onDone;
|
||||
if (willChange) {
|
||||
if (change) {
|
||||
// If the key triggers a ruleview-changed, wait for that event, it will
|
||||
// always be the last to be triggered and tells us when the preview has
|
||||
// been done.
|
||||
@ -107,12 +111,11 @@ function* testCompletion([key, modifiers, completion, index, total, willChange],
|
||||
editor = inplaceEditor(view.styleDocument.activeElement);
|
||||
is(editor.input.value, completion, "Correct value is autocompleted");
|
||||
}
|
||||
if (total == 0) {
|
||||
if (!open) {
|
||||
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
|
||||
} else {
|
||||
ok(editor.popup._panel.state == "open" ||
|
||||
editor.popup._panel.state == "showing", "Popup is open");
|
||||
is(editor.popup.getItems().length, total, "Number of suggestions match");
|
||||
is(editor.popup.selectedIndex, index, "Correct item is selected");
|
||||
is(editor.popup.selectedIndex != -1, selected, "An item is selected");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user