// 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;
// 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();
},
() => {
ok(false, "Error callback of watchPosition must not be called.");
}
);
});
const currentPositionPromise = new Promise((resolve) => {
geo.getCurrentPosition(
() => {
ok(success, "getCurrentPosition was called.");
if (!success){
throw new Error("getCurrentPosition was called too early");
}
resolve();
},
() => {
ok(false, "Error callback of getCurrentPosition must not be called.");
}
);
});
// Send data to be ignored...
await p(start_sending_garbage);
await p(stop_sending_garbage);
await p(resume_geolocationProvider);
// 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
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
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.