Make service workers behave correctly with regards to Page Cache
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jan 2018 04:08:33 +0000 (04:08 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jan 2018 04:08:33 +0000 (04:08 +0000)
commit718f243f66a6ad6f5e03d96159e0f31017cded95
tree8af3f4f35602d58f75be56732ac47b203a41b261
parent2f2688aa15fcb253a9b9e7a69c31da7a2c98ac53
Make service workers behave correctly with regards to Page Cache
https://bugs.webkit.org/show_bug.cgi?id=181446
<rdar://problem/36164291>

Reviewed by Youenn Fablet.

Source/WebCore:

Make service workers behave correctly with regards to Page Cache:
1. If a document has an active service worker, do not let it go into PageCache
2. When a document goes into page cache, unregister it from the list of service worker clients
3. When a document is restored from page cache, add it nack to the list of service worker clients

Tests: http/tests/workers/service/client-added-to-clients-when-restored-from-page-cache.html
       http/tests/workers/service/client-removed-from-clients-while-in-page-cache.html
       http/tests/workers/service/no-page-cache-when-controlled.html
       http/tests/workers/service/other_resources/test.html

* dom/Document.cpp:
(WebCore::Document::suspend):
(WebCore::Document::resume):
* history/PageCache.cpp:
(WebCore::canCacheFrame):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::serviceWorkerKey):
* page/DiagnosticLoggingKeys.h:

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/client-added-to-clients-when-restored-from-page-cache-expected.txt: Added.
* http/tests/workers/service/client-added-to-clients-when-restored-from-page-cache.html: Added.
* http/tests/workers/service/client-removed-from-clients-while-in-page-cache-expected.txt: Added.
* http/tests/workers/service/client-removed-from-clients-while-in-page-cache.html: Added.
* http/tests/workers/service/no-page-cache-when-controlled-expected.txt: Added.
* http/tests/workers/service/no-page-cache-when-controlled.html: Added.
* http/tests/workers/service/other_resources/test.html: Added.
* http/tests/workers/service/resources/getClientCount-worker.js: Added.
(event.then):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226677 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/client-added-to-clients-when-restored-from-page-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/client-added-to-clients-when-restored-from-page-cache.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/client-removed-from-clients-while-in-page-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/client-removed-from-clients-while-in-page-cache.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/no-page-cache-when-controlled-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/no-page-cache-when-controlled.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/other_resources/test.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/getClientCount-worker.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/history/PageCache.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h