blob: cfdb17d8da939c9e2b1700c0f8307bf1ca86e4b6 (
plain)
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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the accepting an autocompletion does not scroll the input.
const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>
<script>
/* Create a prototype-less object so popup does not contain native
* Object prototype properties.
*/
window.foobar = Object.create(null, Object.getOwnPropertyDescriptors({
item0: "value0",
item1: "value1",
}));
</script>`;
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm, ui } = hud;
const { autocompletePopup: popup } = jsterm;
info("Insert multiple new lines so the input overflows");
const onPopUpOpen = popup.once("popup-opened");
const lines = "\n".repeat(200);
setInputValue(hud, lines);
info("Fire the autocompletion popup");
EventUtils.sendString("window.foobar.");
await onPopUpOpen;
const scrollableEl = ui.window.document.querySelector(".CodeMirror-scroll");
Assert.greater(scrollableEl.scrollTop, 0, "The input overflows");
const scrollTop = scrollableEl.scrollTop;
info("Hit Enter to accept the autocompletion");
const onPopupClose = popup.once("popup-closed");
EventUtils.synthesizeKey("KEY_Enter");
await onPopupClose;
ok(!popup.isOpen, "popup is not open after KEY_Enter");
is(
getInputValue(hud),
lines + "window.foobar.item0",
"completion was successful after KEY_Enter"
);
is(
scrollableEl.scrollTop,
scrollTop,
"The scrolling position stayed the same when accepting the completion"
);
});
|