Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_doc_busy.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/accessible/tests/mochitest/states/test_doc_busy.html


<!DOCTYPE html>
<html>
<head>
  <title>states of document</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../states.js"></script>
  <script type="application/javascript"
          src="../promisified-events.js"></script>

  <script type="application/javascript">
    const { BrowserTestUtils } = ChromeUtils.importESModule(
      "resource://testing-common/BrowserTestUtils.sys.mjs");
    const { Downloads } = ChromeUtils.importESModule(
      "resource://gre/modules/Downloads.sys.mjs");

    function matchDocBusyChange(isBusy) {
      return function(event) {
        const scEvent = event.QueryInterface(nsIAccessibleStateChangeEvent);
        return (
          event.DOMNode == document &&
          scEvent.state === STATE_BUSY &&
          scEvent.isEnabled === isBusy
        );
      };
    }

    function getDownloadStartedPromise() {
      return Downloads.getList(Downloads.PUBLIC).then(list => {
        return new Promise(resolve => {
          list.addView({
            onDownloadAdded(download) {
              resolve(download);
            }
          })
        });
      });
    }

    async function downloadHandled(downloadResult) {
      if (Window.isInstance(downloadResult)) {
        return BrowserTestUtils.closeWindow(downloadResult);
      }
      // downloadResult is a download object.
      await downloadResult.finalize(true);
      return Downloads.getList(Downloads.PUBLIC).then(list => list.remove(downloadResult));
    }

    async function doTest() {
      // Because of variable timing, there are two acceptable possibilities:
      // 1. We get an event for busy and an event for not busy.
      // 2. The two events get coalesced, so no events are fired.
      // However, we fail this test if we get the first event but not the
      // second.
      let gotBusy = false;
      let gotNotBusy = false;
      const busyEvents = async function() {
        await waitForEvent(EVENT_STATE_CHANGE, matchDocBusyChange(true));
        info("Got busy event");
        gotBusy = true;
        await waitForEvent(EVENT_STATE_CHANGE, matchDocBusyChange(false));
        info("Got not-busy event");
        gotNotBusy = true;
      }();

      const downloadStarted = getDownloadStartedPromise();

      info("Clicking link to trigger download");
      synthesizeMouse(getNode("link"), 1, 1, {});
      info("Waiting for download prompt to open");
      const downloadResult = await downloadStarted;

      // Once we no longer show a dialog for downloads, the not busy event
      // might show up a bit later.
      if (gotBusy && !gotNotBusy) {
        await busyEvents;
      }

      // Any busy events should have been fired by the time the download
      // prompt has opened.
      if (gotBusy && gotNotBusy) {
        ok(true, "Got both busy change and not-busy change");
      } else if (!gotBusy && !gotNotBusy) {
        ok(true, "No busy events, coalesced");
      } else {
        ok(false, "Got busy change but didn't get not-busy change!");
      }
      testStates(document, 0, 0, STATE_BUSY, 0, "Document not busy");

      // Clean up.
      info("Closing download prompt");
      await downloadHandled(downloadResult);
      // We might still be waiting on busy events. Remove any pending observers.
      for (let observer of Services.obs.enumerateObservers(
        "accessible-event")
      ) {
        Services.obs.removeObserver(observer, "accessible-event");
      }

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>

<body>

  <a target="_blank"
     title="Missing busy state change event when downloading files"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=446469">Bug 446469</a>

  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <a id="link" href="http://example.com/a11y/accessible/tests/mochitest/dumbfile.zip">a file</a>
</body>
</html>

Messung V0.5
C=93 H=93 G=92

¤ Dauer der Verarbeitung: 0.0 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 und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge