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

"use strict";

// See Bug 585991.

const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>Autocomplete await expression`;

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

  info("Check that the await keyword is in the autocomplete");
  await setInputValueForAutocompletion(hud, "aw");
  checkInputCompletionValue(hud, "ait", "completeNode has expected value");

  EventUtils.synthesizeKey("KEY_Tab");
  is(getInputValue(hud), "await", "'await' tab completion");

  const updated = jsterm.once("autocomplete-updated");
  EventUtils.sendString(" ");
  await updated;

  info("Check that the autocomplete popup is displayed");
  const onPopUpOpen = autocompletePopup.once("popup-opened");
  EventUtils.sendString("P");
  await onPopUpOpen;

  ok(autocompletePopup.isOpen, "popup is open");
  ok(
    autocompletePopup.items.some(item => item.label === "Promise"),
    "popup has expected `Promise` item"
  );
});