tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_jsterm_await_concurrent_same_result.js (1145B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Test that hitting Ctrl + E does toggle the editor mode.
      5 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1519105
      6 
      7 "use strict";
      8 
      9 const TEST_URI =
     10  "data:text/html;charset=utf-8,<!DOCTYPE html>Test concurrent top-level await expressions returning same value";
     11 
     12 add_task(async function () {
     13  // Enable editor mode as we'll be able to quicly trigger multiple evaluations.
     14  await pushPref("devtools.webconsole.input.editor", true);
     15 
     16  const hud = await openNewTabAndConsole(TEST_URI);
     17  setInputValue(
     18    hud,
     19    `await new Promise(res => setTimeout(() => res("foo"), 5000))`
     20  );
     21 
     22  info("Evaluate the expression 3 times in a row");
     23  const executeButton = hud.ui.outputNode.querySelector(
     24    ".webconsole-editor-toolbar-executeButton"
     25  );
     26 
     27  executeButton.click();
     28  executeButton.click();
     29  executeButton.click();
     30 
     31  await waitFor(
     32    () => findEvaluationResultMessages(hud, "foo").length === 3,
     33    "Waiting for all results to be printed in console",
     34    1000
     35  );
     36  ok(true, "There are as many results as commands");
     37 });