[chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
https://bugs.webkit.org/show_bug.cgi?id=105367

Reviewed by Dmitry Titov.

Source/WebCore:

Eliminated a Chromium-specific object wrapping WorkerMessagingProxy in order to fix a
lifetime management bug, which leaked every Document which started a dedicated worker.

Test: fast/workers/worker-document-leak.html

* workers/WorkerLoaderProxy.h:
(WorkerLoaderProxy):
    Added Chromium-specific casting method to bridge two now-distinct class hierarchies.
* workers/WorkerMessagingProxy.h:
(WorkerMessagingProxy):
    Made destructor protected instead of private to allow subclassing.

Source/WebKit/chromium:

Made WebWorkerClientImpl a subclass of WorkerMessagingProxy rather than an object wrapping
WorkerMessagingProxy. WorkerMessagingProxy manages its own lifetime and it is impossible to
properly synchronize the lifetime of WebWorkerClientImpl separately.

This allowed most of WebWorkerClientImpl to be deleted, but forced a divergence in the class
hierarchies of WebWorkerClientImpl and WebSharedWorkerImpl. Conversion methods were added to
WorkerLoaderProxy and WebWorkerBase to bridge the hierarchies of in-process and
out-of-process workers.

* src/DatabaseObserver.cpp:
(WebCore::DatabaseObserver::canEstablishDatabase):
    Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
* src/IDBFactoryBackendProxy.cpp:
(WebKit::AllowIndexedDBMainThreadBridge::signalCompleted):
    Adjusted how WorkerLoaderProxy's methods are called.
(WebKit::IDBFactoryBackendProxy::allowIndexedDB):
    Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
* src/LocalFileSystemChromium.cpp:
(WebCore::openFileSystemHelper):
    Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
* src/WebSharedWorkerImpl.cpp:
(WebKit::WebSharedWorkerImpl::toWebWorkerBase):
    Implemented new conversion method.
* src/WebSharedWorkerImpl.h:
(WebSharedWorkerImpl):
    Explicitly derive from WorkerLoaderProxy now that WebWorkerBase no longer does.
(WebKit::WebSharedWorkerImpl::workerLoaderProxy):
    Added new conversion method.
* src/WebWorkerBase.h:
(WebWorkerBase):
    Removed derivation from WorkerLoaderProxy. Added method to convert to WorkerLoaderProxy.
* src/WebWorkerClientImpl.cpp:
(WebKit):
    Adjusted comment.
(WebKit::WebWorkerClientImpl::createWorkerContextProxy):
    Adjusted whitespace.
(WebKit::WebWorkerClientImpl::terminateWorkerContext):
    Eliminated delegation to separate object.
(WebKit::WebWorkerClientImpl::toWebWorkerBase):
    Implemented new conversion method.
(WebKit::WebWorkerClientImpl::view):
(WebKit::WebWorkerClientImpl::allowDatabase):
(WebKit::WebWorkerClientImpl::allowFileSystem):
(WebKit::WebWorkerClientImpl::openFileSystem):
(WebKit::WebWorkerClientImpl::allowIndexedDB):
    Eliminated delegation to separate object.
(WebKit::WebWorkerClientImpl::WebWorkerClientImpl):
* src/WebWorkerClientImpl.h:
(WebKit):
    Changed to inherit from WorkerMessagingProxy directly.
(WebWorkerClientImpl):
    Deleted most methods previously overridden from WorkerContextProxy, etc.
* src/WorkerAsyncFileSystemChromium.cpp:
(WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
(WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):
    Hold on to, and use, WorkerLoaderProxy rather than WebWorkerBase.
* src/WorkerAsyncFileSystemChromium.h:
(WebKit):
(WebCore):
(WorkerAsyncFileSystemChromium):
    Hold on to WorkerLoaderProxy rather than WebWorkerBase.

LayoutTests:

* fast/workers/resources/empty-worker.js: Added.
* fast/workers/resources/worker-document-leak-iframe.html: Added.
* fast/workers/worker-document-leak-expected.txt: Added.
* fast/workers/worker-document-leak.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add flaky crash expectations for multiple tests on Mac WebKit2.

* platform/mac-wk2/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138694 268f45cc-cd09-0410-ab3c-d52691b4dbfc