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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the main expression is eagerly evaluated and its results are used in the autocomple popup
"use strict";
const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>Test autocompletion for expression variables<script>
var testObj = {
fun: () => ({ yay: "yay", yo: "yo", boo: "boo" })
};
</script>`;
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm } = hud;
const { autocompletePopup } = jsterm;
const cases = [
{ input: "testObj.fun().y", results: ["yay", "yo"] },
{
input: `Array.of(1,2,3).reduce((i, agg) => agg + i).toS`,
results: ["toString"],
},
{ input: `1..toE`, results: ["toExponential"] },
];
for (const test of cases) {
info(`Test: ${test.input}`);
await setInputValueForAutocompletion(hud, test.input);
ok(
hasExactPopupLabels(autocompletePopup, test.results),
"Autocomplete popup shows expected results: " +
getAutocompletePopupLabels(autocompletePopup).join("\n")
);
}
});
|