Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/devtools/client/framework/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  browser_toolbox_races.js   Sprache: JAVA

 
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */


"use strict";

// Toggling the toolbox three time can take more than 45s on slow test machine
requestLongerTimeout(2);

// Test toggling the toolbox quickly and see if there is any race breaking it.

const URL = "data:text/html;charset=utf-8,Toggling devtools quickly";
const {
  gDevToolsBrowser,
} = require("resource://devtools/client/framework/devtools-browser.js");

add_task(async function () {
  // Make sure this test starts with the selectedTool pref cleared. Previous
  // tests select various tools, and that sets this pref.
  Services.prefs.clearUserPref("devtools.toolbox.selectedTool");

  await addTab(URL);

  let ready = 0,
    destroy = 0,
    destroyed = 0;
  const onReady = () => {
    ready++;
  };
  const onDestroy = () => {
    destroy++;
  };
  const onDestroyed = () => {
    destroyed++;
  };
  gDevTools.on("toolbox-ready", onReady);
  gDevTools.on("toolbox-destroy", onDestroy);
  gDevTools.on("toolbox-destroyed", onDestroyed);

  // The current implementation won't toggle the toolbox many times,
  // instead it will ignore toggles that happens while the toolbox is still
  // creating or still destroying.

  info("Toggle the toolbox many times in a row");
  toggle();
  toggle();
  toggle();
  toggle();
  toggle();
  await wait(500);

  await waitFor(() => ready == 1);
  is(
    ready,
    1,
    "No matter how many times we called toggle, it will only open the toolbox once"
  );
  is(
    destroy,
    0,
    "All subsequent, synchronous call to toggle will be ignored and the toolbox won't be destroyed"
  );
  is(destroyed, 0);

  info("Retoggle the toolbox many times in a row");
  toggle();
  toggle();
  toggle();
  toggle();
  toggle();
  await wait(500);

  await waitFor(() => destroyed == 1);
  is(destroyed, 1, "Similarly, the toolbox will be closed");
  is(destroy, 1);
  is(
    ready,
    1,
    "and no other toolbox will be opened. The subsequent toggle will be ignored."
  );

  gDevTools.off("toolbox-ready", onReady);
  gDevTools.off("toolbox-destroy", onDestroy);
  gDevTools.off("toolbox-destroyed", onDestroyed);
  await wait(1000);

  gBrowser.removeCurrentTab();
});

function toggle() {
  // When enabling the input event prioritization, we'll reserve some time to
  // process input events in each frame. In that case, the synthesized input
  // events may delay the normal events. Replace synthesized key events by
  // toggleToolboxCommand to prevent the synthesized input events jam the
  // content process and cause the test timeout.
  gDevToolsBrowser.toggleToolboxCommand(window.gBrowser);
}

94%


¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.