1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests the suggest completion popup behavior of CSS property field.
const TEST_URI = "<h1 style='color: lime'>Header</h1>";
add_task(async function () {
await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
const { inspector, view } = await openRuleView();
info("Selecting the test node");
await selectNode("h1", inspector);
const prop = getTextProperty(view, 0, { color: "lime" });
info("Test with css property value field");
await testCompletion(view, prop.editor.valueSpan, true);
info("Test with css property name field");
await testCompletion(view, prop.editor.nameSpan, false);
});
async function testCompletion(view, target, isExpectedOpenPopup) {
const editor = await focusEditableField(view, target);
info(
"Check the suggest completion popup visibility after clearing the field"
);
const onChanged = view.once("ruleview-changed");
const popupEvent = isExpectedOpenPopup ? "popup-opened" : "popup-closed";
const onPopupEvent =
editor.popup.isOpen === isExpectedOpenPopup
? Promise.resolve()
: once(view.popup, popupEvent);
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, view.styleWindow);
// Flush the debounce to update the preview text.
view.debounce.flush();
await Promise.all([onChanged, onPopupEvent]);
is(
editor.popup.isOpen,
isExpectedOpenPopup,
"The popup visibility is correct"
);
if (editor.popup.isOpen) {
info("Close the suggest completion popup");
const closingEvents = [
view.once("ruleview-changed"),
once(view.popup, "popup-closed"),
];
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
await Promise.all(closingEvents);
}
}
|