From 0345f1680abd918dc9c8e335810cd697366cf19f Mon Sep 17 00:00:00 2001 From: Dave Tapuska Date: Mon, 26 Aug 2019 11:29:52 +0000 Subject: [PATCH] Bug 1570776 [wpt PR 17554] - Add ability for service worker to filter out frozen windows., a=testonly Automatic update from web-platform-tests Add ability for service worker to filter out frozen windows. Add code to support handling of frozen clients. Frozen clients do not run their event loop, so postMessage to them just causes problems. To allow service workers to continue working with frozen windows we expose includeFrozen in the matchAll and the frozen attribute on the Client. If a service worker calls focus on a client it will unfreeze the window when it is moved to have focus. This feature is currently marked as experimental and an intent to ship will be sent. This is specified in https://wicg.github.io/page-lifecycle/ and https://github.com/w3c/ServiceWorker/pull/1442 BUG=957597 Change-Id: I6abe1882e88c65dac99250db5bb7fa8d3a4b2b1d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677065 Commit-Queue: Ken Buchanan Reviewed-by: Ken Buchanan Reviewed-by: Matt Falkenhagen Cr-Commit-Position: refs/heads/master@{#689558} -- wpt-commits: 3d052c54485970c1673500c1ba7d52182adf6f4f wpt-pr: 17554 --- .../clients-matchall-frozen.https.html | 103 ++++++++++++++++++ .../resources/clients-frame-freeze.html | 15 +++ .../resources/clients-matchall-worker.js | 19 +++- 3 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-matchall-frozen.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-frame-freeze.html diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-matchall-frozen.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-frozen.https.html new file mode 100644 index 0000000000000..ef27ac3d372e5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-frozen.https.html @@ -0,0 +1,103 @@ + +Service Worker: Clients.matchAll + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-frame-freeze.html b/testing/web-platform/tests/service-workers/service-worker/resources/clients-frame-freeze.html new file mode 100644 index 0000000000000..7468a660e9085 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-frame-freeze.html @@ -0,0 +1,15 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js index d6634f4d40ef6..13e111a2f9146 100644 --- a/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js @@ -13,11 +13,20 @@ self.onmessage = function(e) { // In that case, just pretend it's top-level! frame_type = 'top-level'; } - message.push([client.visibilityState, - client.focused, - client.url, - client.type, - frame_type]); + if (e.data.includeLifecycleState) { + message.push({visibilityState: client.visibilityState, + focused: client.focused, + url: client.url, + lifecycleState: client.lifecycleState, + type: client.type, + frameType: frame_type}); + } else { + message.push([client.visibilityState, + client.focused, + client.url, + client.type, + frame_type]); + } }); // Sort by url if (!e.data.disableSort) {