Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web Inspector doesn't show nested workers
https://bugs.webkit.org/show_bug.cgi?id=255402 <rdar://problem/108322385> Reviewed by Alexey Proskuryakov. This allows for sub-`Worker` to appear in Web Inspector in the same way as the parent `Worker`. * Source/JavaScriptCore/inspector/protocol/Worker.json: * Source/WebCore/inspector/InspectorController.cpp: (WebCore::InspectorController::createLazyAgents): * Source/WebCore/inspector/WorkerInspectorController.cpp: (WebCore::WorkerInspectorController::createLazyAgents): * Source/WebCore/inspector/agents/InspectorWorkerAgent.h: * Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp: (WebCore::InspectorWorkerAgent::InspectorWorkerAgent): (WebCore::InspectorWorkerAgent::enable): (WebCore::InspectorWorkerAgent::connectToAllWorkerInspectorProxiesForPage): Deleted. * Source/WebCore/inspector/agents/page/PageWorkerAgent.h: Added. * Source/WebCore/inspector/agents/page/PageWorkerAgent.cpp: Added. (WebCore::PageWorkerAgent::PageWorkerAgent): (WebCore::PageWorkerAgent::connectToAllWorkerInspectorProxies): * Source/WebCore/inspector/agents/worker/WorkerWorkerAgent.h: Added. * Source/WebCore/inspector/agents/worker/WorkerWorkerAgent.cpp: Added. (WebCore::WorkerWorkerAgent::WorkerWorkerAgent): (WebCore::WorkerWorkerAgent::connectToAllWorkerInspectorProxies): Add support for the `Worker` inspector protocol domain inside `"worker"` inspector targets. * Source/WebCore/bindings/js/WorkerModuleScriptLoader.h: * Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp: (WebCore::WorkerModuleScriptLoader::load): (WebCore::WorkerModuleScriptLoader::notifyFinished): * Source/WebCore/fileapi/FileReaderLoader.h: * Source/WebCore/fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::didReceiveResponse): (WebCore::FileReaderLoader::didFinishLoading): (WebCore::FileReaderLoader::didFail): * Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorThreadableLoaderClient::didReceiveResponse): (WebCore::InspectorThreadableLoaderClient::didFinishLoading): (WebCore::InspectorThreadableLoaderClient::didFail): * Source/WebCore/loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::cancel): (WebCore::DocumentThreadableLoader::didReceiveResponse): (WebCore::DocumentThreadableLoader::didFinishLoading): (WebCore::DocumentThreadableLoader::didFail): (WebCore::DocumentThreadableLoader::preflightFailure): (WebCore::DocumentThreadableLoader::logErrorAndFail): * Source/WebCore/loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didReceiveResponse): (WebCore::ThreadableLoaderClient::didFinishLoading): (WebCore::ThreadableLoaderClient::didFail): * Source/WebCore/loader/ThreadableLoaderClientWrapper.h: (WebCore::ThreadableLoaderClientWrapper::didReceiveResponse): (WebCore::ThreadableLoaderClientWrapper::didFinishLoading): (WebCore::ThreadableLoaderClientWrapper::didFail): (WebCore::ThreadableLoaderClientWrapper::didReceiveAuthenticationCancellation): Deleted. * Source/WebCore/loader/WorkerThreadableLoader.h: * Source/WebCore/loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::cancel): (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse): (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveData): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail): * Source/WebCore/Modules/fetch/FetchLoader.h: * Source/WebCore/Modules/fetch/FetchLoader.cpp: (WebCore::FetchLoader::didReceiveResponse): (WebCore::FetchLoader::didFinishLoading): (WebCore::FetchLoader::didFail): * Source/WebCore/Modules/notifications/NotificationResourcesLoader.h: * Source/WebCore/Modules/notifications/NotificationResourcesLoader.cpp: (WebCore::NotificationResourcesLoader::ResourceLoader::didReceiveResponse): (WebCore::NotificationResourcesLoader::ResourceLoader::didFinishLoading): (WebCore::NotificationResourcesLoader::ResourceLoader::didFail): * Source/WebCore/page/EventSource.h: * Source/WebCore/page/EventSource.cpp: (WebCore::EventSource::didReceiveResponse): (WebCore::EventSource::didFinishLoading): (WebCore::EventSource::didFail): * Source/WebCore/workers/Worker.h: * Source/WebCore/workers/Worker.cpp: (WebCore::Worker::didReceiveResponse): (WebCore::Worker::notifyFinished): * Source/WebCore/workers/WorkerFontLoadRequest.h: * Source/WebCore/workers/WorkerFontLoadRequest.cpp: (WebCore::WorkerFontLoadRequest::didReceiveResponse): (WebCore::WorkerFontLoadRequest::didFinishLoading): (WebCore::WorkerFontLoadRequest::didFail): * Source/WebCore/workers/WorkerScriptLoader.h: * Source/WebCore/workers/WorkerScriptLoader.cpp: (WebCore::WorkerScriptLoader::didReceiveResponse): (WebCore::WorkerScriptLoader::didFinishLoading): (WebCore::WorkerScriptLoader::didFail): (WebCore::WorkerScriptLoader::notifyError): (WebCore::WorkerScriptLoader::notifyFinished): * Source/WebCore/workers/WorkerScriptLoaderClient.h: * Source/WebCore/workers/service/ServiceWorkerJob.h: * Source/WebCore/workers/service/ServiceWorkerJob.cpp: (WebCore::ServiceWorkerJob::didReceiveResponse): (WebCore::ServiceWorkerJob::notifyFinished): * Source/WebCore/workers/shared/SharedWorkerScriptLoader.h: * Source/WebCore/workers/shared/SharedWorkerScriptLoader.cpp: (WebCore::SharedWorkerScriptLoader::didReceiveResponse): (WebCore::SharedWorkerScriptLoader::notifyFinished): * Source/WebCore/xml/XMLHttpRequest.h: * Source/WebCore/xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::didFail): (WebCore::XMLHttpRequest::didFinishLoading): (WebCore::XMLHttpRequest::didReceiveResponse): Pass along the toplevel `ScriptExecutionContextIdentifier` so that clients can use that to get the toplevel context and do things with it (e.g. "notify the `Document` that this load has finished"). This is used by Web Inspector because `Worker` do not have an `InspectorNetworkAgent`, meaning that any `InspectorInstrumentation` that pipe through to it need to be done on the same thread as the `Document`. * Source/WebCore/workers/WorkerGlobalScope.cpp: (WebCore::WorkerGlobalScope::importScripts): Remove redundant `InspectorInstrumentation` call. * Source/WebInspectorUI/UserInterface/Controllers/WorkerManager.js: (WI.WorkerManager): (WI.WorkerManager.prototype.workerCreated): (WI.WorkerManager.prototype.workerTerminated): (WI.WorkerManager.prototype.dispatchMessageFromWorker): Keep a multimap of sub-`Worker` for each `Worker`. * Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js: (WI.DebuggerManager.prototype.scriptDidParse): * Source/WebInspectorUI/UserInterface/Models/Script.js: (WI.Script.prototype.couldBeMainResource): Added. (WI.Script.prototype._resolveResource): `InspectorInstrumentation::didReceiveScriptResponse` is not always called in time before `Network.responseReceived` due to the fact that the `Worker` was created on another thread (i.e. sub-`Worker`), the `WI.Script` was loaded from memory cache, or some other reason. As such, we cannot rely on `WI.Resource.Type.Script` being the only way to associate a `WI.Resource` with a `WI.Script`. In the sub-`Worker` scenario, do a second pass to see if any `WI.Resource` with the same URL happen to have a script MIME type (even though they're marked as some other type) and associate with that. * Source/WebInspectorUI/UserInterface/Views/QuickConsole.js: (WI.QuickConsole): (WI.QuickConsole.prototype.closed): (WI.QuickConsole.prototype._populateActiveExecutionContextNavigationItemContextMenu): (WI.QuickConsole.prototype._handleTargetAdded): Added. Show sub-`Worker` underneath and indented from the parent `Worker`. Also refresh the execution context picker when new targets (e.g. `Worker`) are added. * Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange): Only use the associated `WI.Resource` when showing a `WI.Script` if it's not the main resource. Otherwise, things like `WI.WorkerTreeElement` that use the `WI.Script` as the `representedObject` won't be found when searching for a `WI.TreeElement` matching the `representedObject`. * Source/WebCore/inspector/InspectorInstrumentation.h: * Source/WebCore/inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::instrumentingAgents): (WebCore::InspectorInstrumentation::willSendRequest): (WebCore::InspectorInstrumentation::didReceiveResourceResponse): (WebCore::InspectorInstrumentation::didReceiveData): (WebCore::InspectorInstrumentation::didFinishLoading): (WebCore::InspectorInstrumentation::didFailLoading): (WebCore::InspectorInstrumentation::didReceiveScriptResponse): Drive-by: Mark instrumentation only used by `ServiceWorker` as such. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * LayoutTests/inspector/worker/resources/subworker-manager.js: Added. * LayoutTests/inspector/worker/resources/worker-utilities.js: (TestPage.registerInitializer.awaitTarget): Added. * LayoutTests/inspector/worker/console-basic-subworker.html: Added. * LayoutTests/inspector/worker/console-basic-subworker-expected.txt: Added. * LayoutTests/inspector/worker/debugger-pause-subworker.html: Added. * LayoutTests/inspector/worker/debugger-pause-subworker-expected.txt: Added. * LayoutTests/inspector/worker/resources-in-subworker.html: Added. * LayoutTests/inspector/worker/resources-in-subworker-expected.txt: Added. * LayoutTests/inspector/worker/runtime-basic-subworker.html: Added. * LayoutTests/inspector/worker/runtime-basic-subworker-expected.txt: Added. * LayoutTests/platform/mac-site-isolation/TestExpectations: Canonical link: https://commits.webkit.org/279793@main
- Loading branch information