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
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test to make sure that the editor reacts to preference changes
const CARET_BLINK_TIME = "ui.caretBlinkTime";
add_task(async function () {
Services.prefs.clearUserPref(CARET_BLINK_TIME);
info(`Test when "${CARET_BLINK_TIME}" isn't set`);
let { ed, win } = await setup();
checkCssCustomPropertyValue(
ed,
530,
"When preference isn't set, blink time is set to codeMirror default"
);
ed.destroy();
win.close();
info(`Test with a positive value for "${CARET_BLINK_TIME}"`);
let blinkTime = 200;
Services.prefs.setIntPref(CARET_BLINK_TIME, blinkTime);
({ ed, win } = await setup());
checkCssCustomPropertyValue(
ed,
blinkTime,
"When preference is set, blink time reflects the pref value"
);
ed.destroy();
win.close();
info(`Test when "${CARET_BLINK_TIME}" is 0`);
blinkTime = 0;
Services.prefs.setIntPref(CARET_BLINK_TIME, blinkTime);
({ ed, win } = await setup());
checkCssCustomPropertyValue(
ed,
blinkTime,
"When preference value is 0, blink time is also 0"
);
ed.destroy();
win.close();
info(`Test when "${CARET_BLINK_TIME}" is -1`);
blinkTime = -1;
Services.prefs.setIntPref(CARET_BLINK_TIME, blinkTime);
({ ed, win } = await setup());
checkCssCustomPropertyValue(
ed,
0,
"When preference value is negative, blink time is 0"
);
ed.destroy();
win.close();
Services.prefs.clearUserPref(CARET_BLINK_TIME);
});
function checkCssCustomPropertyValue(editor, expectedMsValue, assertionText) {
is(
editor.codeMirror
.getWrapperElement()
.style.getPropertyValue("--caret-blink-time"),
`${expectedMsValue}ms`,
assertionText
);
}
|