Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  test_hidden.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/geolocation/test/mochitest/test_hidden.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1653549
-->

<meta charset="utf-8">
<title>Test that geolocation position can't be gotten when document is hidden</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="geolocation_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1653549">Mozilla Bug 1653549</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">

<script class="testbody">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("we need to be sure that all location data has been purged/set");

// Little promise wrapper helper.
function p(f) {
  return new Promise((r) => f(r));
}

resume_geolocationProvider(async () => {
  // Initialize
  await new Promise((r) => force_prompt(true, r));
  const popupWindow = window.open("popup.html");
  popupWindow.opener = window;
  await new Promise((r) =>
    window.addEventListener("message", r, { once: true })
  );

  // Confirm everything is working ok...
  const geo = popupWindow.navigator.geolocation;
  await new Promise((resolve, reject) => {
    geo.getCurrentPosition(resolve, reject);
  });

  // Hide the document...
  const hiddenPromise = new Promise(
    (r) => (popupWindow.document.onvisibilitychange = r)
  );
  await SimpleTest.promiseFocus(window);
  await hiddenPromise;

  // Send data to be ignored...
  await p(start_sending_garbage);
  await p(stop_sending_garbage);
  await p(resume_geolocationProvider);

  // The following promises only resolve successfully when document is visible,
  // meaning that position updates are ignored when the document is hidden.
  let success = false;
  let watchId = null;
  const watchPositionPromise = new Promise((resolve) => {
    watchId = geo.watchPosition(
      () => {
        ok(success, "watchPosition was called.");
        if (!success) {
          throw new Error("watchPosition was called too early");
        }
        resolve();
      },
      () => {
        // It's still allowed to get error when document is hidden
        ok(true, "Error callback of watchPosition was called.");
      }
    );
  });

  const currentPositionPromise = new Promise((resolve, reject) => {
    geo.getCurrentPosition(
      () => {
        ok(success, "getCurrentPosition was called.");
        if (!success){
          throw new Error("getCurrentPosition was called too early");
        }
        resolve();
      },
      () => {
        reject(new Error("Error callback of getCurrentPosition must not be called."))
      }
    );
  });

  // Refocus popup window...
  const visiblePopupPromise = new Promise(
    (r) => (popupWindow.document.onvisibilitychange = r)
  );
  await SimpleTest.promiseFocus(popupWindow);
  await visiblePopupPromise;

  // Resuming the geolocation events must now cause the promises to resolve correctly (with success = true).
  success = true;
  await p(resume_geolocationProvider);
  await Promise.all([currentPositionPromise, watchPositionPromise]);

  // Cleanup and finish!
  geo.clearWatch(watchId);
  await SimpleTest.promiseFocus(window);
  popupWindow.close();
  SimpleTest.finish();
});

</script>
</pre>
</body>
</html>

Messung V0.5 in Prozent
C=86 H=97 G=91

¤ Dauer der Verarbeitung: 0.24 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002