http/tests/workers/service/basic-register.html is a flaky failure.
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 16:10:47 +0000 (16:10 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 16:10:47 +0000 (16:10 +0000)
commit410632f41df2d4305272b5c26ceb0100fc91571a
tree86027cf69a13cf98bbcd1a6bf127db14166a8559
parent210b3e4b4d695b7504d8a7cbdb1265784e743c42
http/tests/workers/service/basic-register.html is a flaky failure.
https://bugs.webkit.org/show_bug.cgi?id=178494
<rdar://problem/35065315>

Reviewed by Youenn Fablet.

In WebSWServerConnection::resolveJobInClient(), when a service worker is
registered, we:
1. Add the origin to the WebSWOriginStore
2. Send the IPC to the WebProcess to notify it that the registration succeeded.

The assumption was that step 1 would be synchronous and would therefore send
the shared memory handle to the WebProcess (if the SharedMemory was invalidated)
*before* step 2.

The issue is that step 1 was scheduling a zero-timer to schedule the addition.
As a result, there was a race and the WebContent process could check the
the WebSWOriginTable *after* being notified that a service worker was registered
but *before* it received the SharedMemory handle for the WebSWOriginTable. This
could lead to false negatives and was causing the layout test to be flaky.

To address the issue, step 1 is now synchronous.

* Shared/SharedStringHashStore.cpp:
(WebKit::SharedStringHashStore::SharedStringHashStore):
(WebKit::SharedStringHashStore::scheduleAddition):
(WebKit::SharedStringHashStore::scheduleRemoval):
(WebKit::SharedStringHashStore::contains):
(WebKit::SharedStringHashStore::flushPendingChanges):
(WebKit::SharedStringHashStore::processPendingOperations):
* Shared/SharedStringHashStore.h:
* StorageProcess/ServiceWorker/WebSWOriginStore.cpp:
(WebKit::WebSWOriginStore::add):
(WebKit::WebSWOriginStore::addAll):
(WebKit::WebSWOriginStore::remove):
* StorageProcess/ServiceWorker/WebSWOriginStore.h:
* UIProcess/VisitedLinkStore.cpp:
(WebKit::VisitedLinkStore::addVisitedLinkHash):
(WebKit::VisitedLinkStore::removeVisitedLinkHash):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223690 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/Shared/SharedStringHashStore.cpp
Source/WebKit/Shared/SharedStringHashStore.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.h
Source/WebKit/UIProcess/VisitedLinkStore.cpp