diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html b/testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html new file mode 100644 index 0000000000..512bd14bc6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/enable-client-message-queue.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<script> + // The state variable is used by handle_message to record the time + // at which a message was handled. It's updated by the scripts + // loaded by the <script> tags at the bottom of the file as well as + // by the event listener added here. + var state = 'init'; + addEventListener('DOMContentLoaded', () => state = 'loaded'); + + // We expect to get three ping messages from the service worker. + const expected = ['init', 'install', 'start']; + let promises = {}; + let resolvers = {}; + expected.forEach(name => { + promises[name] = new Promise(resolve => resolvers[name] = resolve); + }); + + // Once all messages have been dispatched, the state in which each + // of them was dispatched is recorded in the draft. At that point + // the draft becomes the final report. + var draft = {}; + var report = Promise.all(Object.values(promises)).then(() => window.draft); + + // This message handler is installed by the 'install' script. + function handle_message(event) { + const data = event.data.data; + draft[data] = state; + resolvers[data](); + } +</script> + +<!-- + The controlling service worker will delay the response to these + fetch requests until the test instructs it how to reply. Note that + the event loop keeps spinning while the parser is blocked. +--> +<script src="empty.js?key=install"></script> +<script src="empty.js?key=start"></script> +<script src="empty.js?key=finish"></script> |