summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_expression_variables.js
blob: 737248aaf82e49328813cb5031349391cdbc0593 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that variable created in the expression are displayed in the autocomplete.

"use strict";

const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>Test autocompletion for expression variables<script>
    var testGlobal;
  </script>`;

add_task(async function () {
  const hud = await openNewTabAndConsole(TEST_URI);
  const { jsterm } = hud;
  const { autocompletePopup } = jsterm;

  await setInputValueForAutocompletion(
    hud,
    `
    var testVar;
    let testLet;
    const testConst;
    class testClass {
      #secret
      #getSecret() {}
    }
    function testFunc(testParam1, testParam2, ...testParamRest) {
      var [testParamRestFirst] = testParamRest;
      let {testDeconstruct1,testDeconstruct2, ...testDeconstructRest} = testParam1;
      test`
  );

  ok(
    hasExactPopupLabels(autocompletePopup, [
      "testClass",
      "testConst",
      "testDeconstruct1",
      "testDeconstruct2",
      "testDeconstructRest",
      "testFunc",
      "testGlobal",
      "testLet",
      "testParam1",
      "testParam2",
      "testParamRest",
      "testParamRestFirst",
      "testVar",
    ]),
    "Autocomplete popup displays both global and local variables"
  );
});