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

// Test that hitting Ctrl + E does toggle the editor mode.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1519105

"use strict";

const TEST_URI =
  "data:text/html;charset=utf-8,<!DOCTYPE html>Test concurrent top-level await expressions returning same value";

add_task(async function () {
  // Enable editor mode as we'll be able to quicly trigger multiple evaluations.
  await pushPref("devtools.webconsole.input.editor", true);

  const hud = await openNewTabAndConsole(TEST_URI);
  setInputValue(
    hud,
    `await new Promise(res => setTimeout(() => res("foo"), 5000))`
  );

  info("Evaluate the expression 3 times in a row");
  const executeButton = hud.ui.outputNode.querySelector(
    ".webconsole-editor-toolbar-executeButton"
  );

  executeButton.click();
  executeButton.click();
  executeButton.click();

  await waitFor(
    () => findEvaluationResultMessages(hud, "foo").length === 3,
    "Waiting for all results to be printed in console",
    1000
  );
  ok(true, "There are as many results as commands");

  Services.prefs.clearUserPref("devtools.webconsole.input.editor");
});